I think I messed up one of my projects and now it won't run almost any command.
Initially I installed all through RVM. The Gemfile shows rails 4.1.3
After some time I think I may tried to update rails and started a couple of other projects which rails version is 4.2.0 and both run fine.
Recently I went back on the first project to deploy it. I was configuring Capistrano when I noticed that I couldn't run any development commands on my working machine. First I tried to run the server but this error appeared:
$ rails server
bin/rails:6: warning: already initialized constant APP_PATH
/home/axl/coding/bfq/bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]
The most common rails commands are:
generate Generate new code (short-cut alias: "g")
console Start the Rails console (short-cut alias: "c")
server Start the Rails server (short-cut alias: "s")
dbconsole Start a console for the database specified in config/database.yml
(short-cut alias: "db")
new Create a new Rails application. "rails new my_app" creates a
new application called MyApp in "./my_app"
In addition to those, there are:
application Generate the Rails application code
destroy Undo code generated with "generate" (short-cut alias: "d")
plugin new Generates skeleton for developing a Rails plugin
runner Run a piece of code in the application environment (short-cut alias: "r")
All commands can be run with -h (or --help) for more information.
So I thought maybe I screw something with Capistrano so I returned to branch master but the error was still there.
Any rake call returns this:
$ rake db:setup
rake aborted!
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.3.2. Prepending `bundle exec` to your command may solve this.
/home/axl/coding/bfq/config/boot.rb:4:in `<top (required)>'
/home/axl/coding/bfq/config/application.rb:1:in `<top (required)>'
/home/axl/coding/bfq fiscal-quadrum/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/home/axl/coding/bfq/config/boot.rb:4:in `<top (required)>'
/home/axl/coding/bfq/config/application.rb:1:in `<top (required)>'
/home/axl/coding/bfq/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Prepending bundle exec as suggested shows another error. For example:
$ bundle exec rake db:setup
rake aborted!
LoadError: cannot load such file -- gserver
/home/axl/coding/bfq/config/application.rb:7:in `<top (required)>'
/home/axl/coding/bfq/Rakefile:4:in `require'
/home/axl/coding/bfq/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
There are similar cases, error bin/rails:6: warning: already initialized constant APP_PATH is related to spring gem. Running rake rails:update:bin seems to help but I can't run it since rake doesn't work at all.
So I tried reinstalling RVM. But nothing changed. I even removed RVM and installed Rbenv. But everything is exactly the same.
Versions inside the project:
$ ruby --version
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
$ gem --version
2.4.5
$ rake --version
rake, version 10.4.2
$ rails --version
Rails 4.1.6
bundle update does some updates but after that executing rake shows the same error as prepending bundle exec:
$ rake
rake aborted!
LoadError: cannot load such file -- gserver
/home/axl/coding/bfq/config/application.rb:7:in `<top (required)>'
/home/axl/coding/bfq/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
And there is nothing useful googling LoadError: cannot load such file -- gserver
Please, help me :'(
Shame on me. I didn't define ruby local version for the project.
When using RVM:
$ rvm install 2.1.1
$ rvm use 2.1.1
For Rbenv:
$ rbenv install 2.1.1
$ rbenv local 2.1.1
Related
I am having an issue while deploying my site to AWS.
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.5.0. Prepending `bundle exec` to your command may solve this.
/var/app/ondeck/config/boot.rb:3:in `<top (required)>'
/var/app/ondeck/config/application.rb:1:in `<top (required)>'
/var/app/ondeck/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/var/app/ondeck/config/boot.rb:3:in `<top (required)>'
/var/app/ondeck/config/application.rb:1:in `<top (required)>'
/var/app/ondeck/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
(ElasticBeanstalk::ExternalInvocationError)
while when I do gem list rake it gives me
*** LOCAL GEMS ***
airbrake (4.3.1)
rake (10.5.0, 10.4.2)
I want to have just one version when I do bundle exec gem uninstall rake -v 10.4.2 it gives me
ERROR: While executing gem ... (Gem::InstallError)
gem "rake" cannot be uninstalled because it is a default gem
How to resolve this issue? any help will be appreciated.
First run bundle update rake .
I hope this works for you.
You need to prefix your command with bundle exec. For example, if your rake command is
rake deploy
You have instead to use
bundle exec rake deploy
Bundler will fetch the proper gem versions as listed in your Gemfile, and execute the command.
I'm having an issue trying to switch the database in my rails app from the out of box sqlite3 to using postgres.
I've run 'gem install pg' and switched the database.yml file to new settings. Also, I've run 'bundle install' in the directory.
Now, when I run 'rake db:setup', I'm receiving this error:
$ rake db:setup
rake aborted!
LoadError: cannot load such file -- rails
/Users/aaa/Documents/Projects/sample_app/config/application.rb:3:in `require'
/Users/aaa/Documents/Projects/sample_app/config/application.rb:3:in `<top (required)>'
/Users/aaa/Documents/Projects/sample_app/Rakefile:4:in `<top (required)>'
/Users/aaa/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
/Users/aaa/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
Any thoughts? Thank you in advance.
Oy, had the wrong version of rails in my gemfile.
If anyone else finds this, make sure running rails -v has your intended result! I was receiving an error when trying to see my rails version, and then changing my gemfile solved the issue.
I am trying to download a Rails app from github and that make it work on my PC. I have read other posts that say you have to run bundle install, rake db:create and then rake db:migrate, I do everything but when I try to run rake db:create I get this error:
rake aborted!
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.3.2. Prepending `bundle exec` to your command may solve this.
D:/art-website/config/boot.rb:4:in `<top (required)>'
D:/art-website/config/application.rb:1:in `<top (required)>'
D:/art-website/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
D:/art-website/config/boot.rb:4:in `<top (required)>'
D:/art-website/config/application.rb:1:in `<top (required)>'
D:/art-website/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
The cause
Your gem rake has a conflicts in the version you have installed i.e. the gem rake your Gemfile requires is of version 10.3.2 while the gem you have on your machine has got version 10.4.2 and 10.3.2.
Solution
uninstall the gem of version 10.4.2. gem uninstall rake would ask you for the version that has to be uninstalled, please select 10.4.2
you may run the commands with bundle exec eg:- bundle exec rake db:migrate or bundle exec rake db:create
you may want to use RVM and use Gemsets as per the projects and its dependency gems. (I would personally prefer this way so that the projects of different version of gems would be clear and no need to worry about the conflicts gem versions)
I have run this rake routes command in terminal but not working, But it's working few days back. Please check it
jaskaran#jaskaran-Vostro-1550:~/rails_project$ rake routes
rake aborted!
Gem::LoadError: You have already activated rake 10.3.2, but your Gemfile requires rake 10.2.2. Prepending `bundle exec` to your command may solve this.
/home/jaskaran/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.6.1/lib/bundler/runtime.rb:34:in `block in setup'
/home/jaskaran/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.6.1/lib/bundler/runtime.rb:19:in `setup'
/home/jaskaran/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.6.1/lib/bundler.rb:120:in `setup'
/home/jaskaran/.rvm/gems/ruby-2.1.0#global/gems/bundler-1.6.1/lib/bundler/setup.rb:7:in `<top (required)>'
/home/jaskaran/rails_project/config/boot.rb:4:in `<top (required)>'
/home/jaskaran/rails_project/config/application.rb:1:in `<top (required)>'
/home/jaskaran/rails_project/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/home/jaskaran/rails_project/config/boot.rb:4:in `<top (required)>'
/home/jaskaran/rails_project/config/application.rb:1:in `<top (required)>'
/home/jaskaran/rails_project/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
Try running bundle exec rake routes to ensure the proper version of Rake gets loaded.
You need to update your gems to the latest available versions: bundle update
Rake versions seems to be different. So, run it as bundle exec rake routes. It should be working.
The correct solution to your problem is to use bundle exec, as suggested by others, to load the version of Rake which your app expects. You may also wish to avoid needing to always run Rake commands with bundle exec. You can either
1) [Recommended] Update your app to use the same version of rake as you have running globally (10.3.2, which is the latest version)
or
2) [Not really recommended] Uninstall version 10.3.2 (actually, any version greater than the one you want) from your global gems and install version 10.2.2 (which your app is currently using)
rvm #global do gem uninstall rake
rvm #global do gem install rake --version 10.2.2
See RVM documentation for global gemsets
at the moment I want to upgrade redmine 1.4.0 to the latest version 2.0.2.
So I followed the howto on this page:
http://www.redmine.org/projects/redmine/wiki/RedmineUpgrade
In short I downloaded the redmine-source and extracted it in a separate folder
"/var/www/redmine-2.0.2"
(whereas my working installation is in /var/www/redmine).
up to Step 3.5 everything went fine but in 3.6
the following happens:
root(at)information:/var/www/redmine-2.0.2# rake config/initializers/session_store.rb
rake aborted!
Don't know how to build task 'config/initializers/session_store.rb'
(See full trace by running task with --trace)
root(at)information:/var/www/redmine-2.0.2# rake --trace
config/initializers/session_store.rb
rake aborted!
Don't know how to build task 'config/initializers/session_store.rb'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/task_manager.rb:49:in `[]'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:115:in `invoke_task'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake -
0.9.2.2/lib/rake/application.rb:94:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:88:in `top_level'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:66:in `block in run'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-
0.9.2.2/lib/rake/application.rb:63:in `run'
/usr/local/rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/bin/rake:33:in `<top
(required)>'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/rake:19:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/rake:19:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
root(at)information:/var/www/redmine-2.0.2#
root(at)information:/var/www/redmine-2.0.2# rake --trace generate_session_store
Invoke generate_session_store (first_time)
Invoke generate_secret_token (first_time)
Invoke config/initializers/secret_token.rb (first_time)
Execute config/initializers/secret_token.rb
Execute generate_secret_token
Execute generate_session_store
Note: The rake task generate_session_store has been deprecated, please use the
replacement version generate_secret_token
root(at)information:/var/www/redmine-2.0.2#
root(at)information:/var/www/redmine-2.0.2# rake generate_session_store
Note: The rake task generate_session_store has been deprecated, please use the
replacement version generate_secret_token
root(at)information:/var/www/redmine-2.0.2# rake --trace generate_secret_token
Invoke generate_secret_token (first_time)
Invoke config/initializers/secret_token.rb (first_time, not_needed)
Execute generate_secret_token
this last step seems to generate "/var/www/redmine-2.0.2/config/initializers/secret_token.rb"
and according to the how to it is a sufficient substitute to the "rake-commands" before.
root(at)information:/var/www/redmine-2.0.2#
root(at)information:/var/www/redmine-2.0.2# rake db:migrate RAILS_ENV=production
root(at)information:/var/www/redmine-2.0.2# rake tmp:cache:clear
root(at)information:/var/www/redmine-2.0.2# rake tmp:sessions:clear
My first prob is how to start the application. I can still go to my old installation "/var/www/redmine"
and start with
ruby ./script/server -e production &
which still works, the output is:
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/activesupport-
2.3.14/lib/active_support/inflector.rb:3:in `<top (required)>': iconv will be deprecated
in the future, use String#encode instead.
=> Booting Mongrel
=> Rails 2.3.14 application starting on http://0.0.0.0:3000
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after
2011-11-01.
Gem.source_index called from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/rails-
2.3.14/lib/rails/gem_dependency.rb:21.
=> Call with -d to detach
=> Ctrl-C to shutdown server
But I can't start the application by going to the new folder "/var/www/redmine-2.0.2/"
and calling
ruby ./script/server -e production &
because there is no file
"/var/www/redmine-2.0.2/script/server".
How can I start the updated version of redmine or is not possible yet ?
I think redmine 2.0.2 needs rails 3.2.5 and I thought I installed
it because:
root(at)information:/var/www/redmine-2.0.2/script# rails -v
Rails 3.2.5
root(at)information:/var/www/redmine-2.0.2/script#
According to the boot protocol above Rails 2.3.14 is used. Wrong ?
Whats my mistake here ? Can somebody give advice howto
succesfully upgrade ?
thanks for your help in advance!
Cheers,
Ansgar
Solve it by using bundle exec rails s -d -e production to start the application in background using the default port (i.e. 3000).
Update
It seems to be an RVM issue, if you open a new shell and running:
$ type rvm | head -1
does not show "rvm is a function", RVM isn't being sourced correctly.
Ensure that RVM is sourced after any path settings as RVM and manipulates the path. If you don't do this, RVM may not work as expected.