Rails Console fails to run

1.9k Views Asked by At

rbenv ruby version: 2.6.6

rails version: 5.1.4

I am working within an older codebase (ruby: 2.6.6 | rails: 5.4.1). This is a codebase I work with daily. I had to download a new ruby version, through rbenv, for a separate repo and in doing so caused quite an issue in my dev environment for the older codebase.

My initial investigation of the issue that popped up led me to delete the rbenv ruby version I had for the older code base (2.6.6), re-install the ruby version, rehash then reinstall bundler.

Previously, I could just run rails command (rails c, rails s) to open the console or run the server. Now I am met with this error when trying to run a rails command:

rbenv: rails: command not found

The `rails' command exists in these Ruby versions:
  2.3.1

When trying to open the rails console with the following commands, bundle exec rails console, bin/rails console, I am met with this error:

`preload': Spring only supports Rails >= 5.2.0 (RuntimeError)

After running bin/rails s, and opening the webpage, the console returns a 500 error:

Completed 500 Internal Server Error in 427ms (ActiveRecord: 0.9ms)


Error during failsafe response: couldn't find file 'ckeditor/init' with type 'application/javascript'
1

There are 1 best solutions below

0
Akram Mohammed On

This isn't the exact answer to your question, but the workaround I did for the "Spring only supports Rails >= 5.2.0" was to just create a new project with rails 5.2.3 or something.

If you want to do the same, you can first list all your local gems by doing gem list rails --local

You will see all your rails versions installed locally.

Then do gem install rails -v '5.2.3'

Now go to a new project directory and run rails _5.2.3_ new appname

Now, you should be able to use the console, generate, migrate and other commands.

You can do bundle install after adding other relevant gems based on your apps requirement.