Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bin/rails:6: warning: already initialized constant APP_PATH #14115

Closed
sadiqmmm opened this issue Feb 19, 2014 · 39 comments
Closed

bin/rails:6: warning: already initialized constant APP_PATH #14115

sadiqmmm opened this issue Feb 19, 2014 · 39 comments

Comments

@sadiqmmm
Copy link
Contributor

I am using RVM. After installing Rails 4.1.0.RC1 and generating new app and running the rails server . Just after pressing the ctrl+ c to close it show the warning -> bin/rails:6: warning: already initialized constant APP_PATH

rails410rc1

@superbilk
Copy link

+1, same here with thin

christian@~/projects/happinessmetric: rails s
=> Booting Thin
=> Rails 4.1.0.rc1 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
Thin web server (v1.6.1 codename Death Proof)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop
^CStopping ...
Exiting
bin/rails:6: warning: already initialized constant APP_PATH
/Users/christian/projects/happinessmetric/bin/rails:6: warning: previous definition of APP_PATH was here

@sadiqmmm
Copy link
Contributor Author

Uninstalling and Re-install RVM helped. Now i am not get this warning.
Use rvm implode to uninstall RVM.

@robin850
Copy link
Member

I do not use RVM and I can see the same warning ; this is pretty strange.

@sadiqmmm
Copy link
Contributor Author

okay, Try to uninstall your ruby and gems . And then restart your computer ,if possible . Again install back ruby and gems and try.

@robin850
Copy link
Member

@sadiqmmm : Actually it's spring which cause this issue. Try to comment it in the Gemfile, then bundle install and restart the server ; shutting it down, the warning is not present anymore.

@robin850
Copy link
Member

Let's continue the disccusion in rails/spring#259. Thank you for reporting!

@sadiqmmm
Copy link
Contributor Author

Thanks +1

@cisolarix
Copy link

rake rails:update:bin to the rescue, don't know why.

@drakmail
Copy link

I'm have this issue when change database adapter in config/database.yml from sqlite3 to postgresql and forgot to add gem 'pg' to my Gemfile. After adding gem 'pg' to Gemfile issue was fixed.

@zackkitzmiller
Copy link

An invalid DATABASE_URL env var can also cause this.

@arcreative
Copy link

Both @cisolarix and @zackkitzmiller suggestions worked to varying degrees, thanks guys!

@tian-xiaobo
Copy link

remove this fix it

begin
load File.expand_path("../spring", FILE)
rescue LoadError
end

@wellington1993
Copy link

@cisolarix , I am run rake rails:update:bin with --traceand identify 2 problematic gems on my Gemfile: this gems: data_miner and sniff. After comment this gems rails s works. Works for me. Thanks.

@SurajShukla
Copy link

I tried by commenting spring gem and updating the bundle, that didn't work..
tried rake rails:update:bin, that didn't work either..

I had require 'iconv' in my application.rb and I removed that from the gem and the server started for me..

Not sure how..

@rlemaster
Copy link

I got this error message after upgrading postgres using brew but not uninstalling and reinstalling the pg gem. This error went away once pg gem was reinstalled.

@joshmn
Copy link
Contributor

joshmn commented Mar 18, 2015

This can be due to an invalid Gemfile.lock -- I've seen it multiple times because people put, say, gem 'dotenv-rails' as the very first gem in their Gemfile (before the rails gem itself, even).

rm Gemfile.lock && bundle

@seangaffney
Copy link

I got this error after removing the brew version of openssl. In my case it was because mysql (also brew installed) was referencing the brew-installed version of openssl. Re-installing mysql via brew resolved the issue.

@b-mandelbrot
Copy link

I got this error when I removed ominiauth gem that was application dependency. I added the gem back to the Gemfile and it worked fine!

@djones
Copy link
Contributor

djones commented May 7, 2015

rake rails:update:bin fixed this for me.

@beck
Copy link

beck commented Jun 10, 2015

rake rails:update:bin 👍

This was removed from the top of the bin:

begin
  load File.expand_path("../spring", __FILE__)
rescue LoadError
end

@Fedcomp
Copy link

Fedcomp commented Jul 2, 2015

This is how i fixed it: use rake -D to figure out what stops rails server from starting. In my case it was missing gem, so i installed it back and it works again.
I really doubt, but in case someone don't know what is spring, it is gem which speedup rails bootup, especially useful in developing rake tasks or running tests.

@cmavromoustakos
Copy link

This fixed it for me as well

[ constantine ~/Sandbox/mavromoustakos ] ✔ rake rails:update:bin                                                                                        
       exist  bin
   identical  bin/bundle
    conflict  bin/rails
    Overwrite /Users/constantine/Sandbox/mavromoustakos/bin/rails? (enter "h" for help) [Ynaqdh] Y
       force  bin/rails
    conflict  bin/rake
    Overwrite /Users/constantine/Sandbox/mavromoustakos/bin/rake? (enter "h" for help) [Ynaqdh] Y
       force  bin/rake
   identical  bin/setup

@Fedcomp
Copy link

Fedcomp commented Jul 6, 2015

@cmavromoustakos this way you just remove rails spring and slowdown rails loading a lot.

@sadaf2605
Copy link

rake rails:update:bin fixed for me too.

@tyronewilson
Copy link

rake rails:update:bin works but at the expense of killing spring. So that isn't a solution if you would like to still keep spring working.

In my case I had forgotten to install sinatra

gem 'sinatra'
bundle install

it worked 100% with spring and everything as before.

@gwzz
Copy link

gwzz commented Oct 6, 2015

I got this problem after I updated to EI Capitan. With:

rake rails:update:bin --trace

I find the problem is caused by bash libmysqlclient.18.dylib
In El Capitan /usr/lib/ now has a restricted flag and can't be written to without disabling security so I just put the link in /usr/local/lib instead,as follows:

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib

Hope this can help anyone who is struggling to the problem.

@kalashnikovisme
Copy link

Fixed.

Remove gem spring
Add gem rest-client

@tyronewilson
Copy link

@kalashnikovisme those things are so unrelated. What was the underlying issue there? did you try keeping spring but adding rest-client and running bundle install && spring stop and restart your app?

Disabling spring seems to be the wrong approach to me, there is usually another issue at play

@kalashnikovisme
Copy link

@tyronewilson problem was in the gem, that uses gem rest-client but doesn't have it in dependency.

And you're right. spring stop solved problem.

@tyronewilson
Copy link

@kalashnikovisme Great! :)

@zulhfreelancer
Copy link

After running sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

I get this error:
ln: /usr/lib/libmysqlclient.18.dylib: Operation not permitted

Then, I run:
brew install mysql it works for me.

@marcellosachs
Copy link

rake rails:update:bin worked for me as well! thanks!

@b3ccio
Copy link

b3ccio commented Feb 12, 2016

+1 for rake rails:update:bin

@tyronewilson
Copy link

Dunno why everyone is so ready to kill spring with this sledgehammer
solution.
On 12 Feb 2016 2:49 AM, "Paul Beccio" notifications@github.com wrote:

+1 for rake rails:update:bin


Reply to this email directly or view it on GitHub
#14115 (comment).

@sibevin
Copy link

sibevin commented May 18, 2016

I have the same issue after I update OSX and brew. Here are steps I solve the problem:

  • I try to reinstall ruby with RVM but not working.
  • Run rake rails:update:bin and an error occurs.
$ rake rails:update:bin
rake aborted!
LoadError: dlopen(/Users/carlos/.rvm/gems/ruby-2.2.3/extensions/x86_64-darwin-14/2.2.0-static/mysql2-0.3.20/mysql2/mysql2.bundle, 9): Library not loaded: /usr/local/lib/libmysqlclient.18.dylib
  Referenced from: /Users/carlos/.rvm/gems/ruby-2.2.3/extensions/x86_64-darwin-14/2.2.0-static/mysql2-0.3.20/mysql2/mysql2.bundle
  Reason: image not found - /Users/carlos/.rvm/gems/ruby-2.2.3/extensions/x86_64-darwin-14/2.2.0-static/mysql2-0.3.20/mysql2/mysql2.bundle
/Users/carlos/.rvm/gems/ruby-2.2.3/gems/mysql2-0.3.20/lib/mysql2.rb:31:in `require'
...
  • It seems that the msyql2 gem is broken, so I reinstall the mysql2 gem (gem uninstall mysql2; bundle install).
  • And it works now.

@wellington1993
Copy link

Hi, I removed require 'bootsnap/setup' from boot.rb and worked for me.

@KiranJosh
Copy link

rake rails:update:bin to the rescue, don't know why.

Worked for me perfectly

@felipecsl
Copy link

With rails 6, bin/rake app:update:bin did the trick

@chunlea
Copy link

chunlea commented Nov 22, 2020

With Rails 6, bin/spring binstub --all works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests