I've tried a number of things like uninstalling/reinstalling rails and gems but to no avail.
When I go into my new project and run rails s or bundle exec rails server I'm getting this error:
bin/rails:6: warning: already initialized constant APP_PATH
/Users/toabui/Sites/cms/bin/rails:6: warning: previous definition of APP_PATH was here Usage: rails COMMAND [ARGS]
Inside my bin/rails I see this code:
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
Does anyone know why I keep getting that error when I run rails s?
I've googled and it seems like there is an error with the spring gem but I can‛t seem to get it to work.
I couldn't find the an_initilizer.rb in my directory and I tried uninstalling/installing the spring gem but it didn't work.
However I did managed to finally get it working.
Apparently there is some conflict with spring and rails 4+.
I needed to run:
rake rails:update:bin
But I ran across another error:
Library not loaded: libmysqlclient.18.dylib
I ran the following command which I found on another stackoverflow post:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
Then ran the original command:
rake rails:update:bin
Then run the server command:
rails s
And now my WebBrick Server is running.
rake rails:update:bin
to the rescue.
If you are on El Capitan (OS X 10.11), Security Integrity Protection (SIP) will prevent linking into /usr/lib to fix mysql. Link it into /usr/local/lib instead:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
This is work for me.
gem uninstall mysql2
bundle install
or gem install mysql2
I was getting the same error. Removed spring from Gemfile and re-bundled. Not really a solution though.
I found the code that created this error in config/initializers/an_initializer.rb
require "lib/a_file_i_need"
I changed it for
require "#{ Rails.root }/lib/a_file_i_need"
I got this error by trying to update rails 4 and imagemagick and rmagick. So I just ran
gem uninstall rmagick
Select the All Versions option. Then try again
EDIT: This happaned again with me just now because I tried to use a gem without installing the required base gem. In my case the solution was to install 'omniauth-google' before trying to use 'omniauth-google-oauth2', but because I didn't install I got the same error again
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With