When i typed: sudo rake db:migrate
I got:
rake aborted !
/home/trace/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end...sion_store :cookie_store, key: '_trace_session'
Note that my version of ruby is:
ruby -v: 1.9.2p312
And that in my bashrc i have:
rvm use 1.9.2-final#rails310.
session_store.rb:
# Be sure to restart your server when you modify this file.
Trace::Application.config.session_store :cookie_store, key: '_trace_session'
Thanks in advance
The problem is that you're using sudo... this is causing the system's Ruby (probably 1.8.7) to be used instead of your rvm Ruby. Just get rid of the sudo and run this:
rake db:migrate
Whenver rvm in used, sudo is skipped unless we need to install system libraries if the gem installation fails which installed in system. All the local gems are used from the gemset or from the global if no gemset is specified.Just have look over a tutorial on web to make things easier in rvm. solution suggested by dylan makes things clear.
Related
Im about to start work on another web application, I change directories to
/rails_projects
and enter
rails new blank
I then get this error
Error: Command not recognized
Usage: rails COMMAND [ARGS]
The common rails commands available for engines are:
generate Generate new code (short-cut alias: "g")
destroy Undo code generated with "generate" (short-cut alias: "d")
All commands can be run with -h for more information.
If you want to run any commands that need to be run in context
of the application, like `rails server` or `rails console`,
you should do it from application's directory (typically test/dummy).
I have reinstalled rails, and still same error, any ideas?
UPDATE:
It actually give me the same error when I type just
rails -h
rails
in cmd
For anyone with a similar error that may land here, this fixed it for me:
rake rails:update:bin
This will generate "new" versions of the binaries. Just say Yes when it inquires you to replace them.
I ran into a similar issue when trying to upgrade a Rails Engine from 3.2 to 4.1.
The culprit was the presence of script/rails which contained:
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/my_project/engine', __FILE__)
require 'rails/all'
require 'rails/engine/commands'
The problem line is there at the end: require 'rails/engine/commands. That was not allowing the full Rails CLI to load which omitted the new command. Removing that file solved my problem.
I'm pretty sure this wasn't the cause of your specific problem, but the symptoms were the same as mine and this was the first link in Google for the error message. Just passing along my findings to help anyone else that runs into this same situation.
It looks like the rails command believes it's inside of a rails engine, which is why a different set of commands are available to you. Notice the 'commands available for engines' text. New is not a command available for engines. I'm not sure why rails thinks the directory you're in is an engine, but likely your directory structure is mixed up somehow.
If anyone runs into this error and needs a last resort plan.
I ended up uninstalling rails, rvm, and installing a newer version of ruby and new gemset.
rvm implode
gem uninstall rails -v=4.0.2
gem uninstall railities
install rvm :
curl -L https://get.rvm.io | bash -s
rvm get stable
for mac:
brew install libtool libxslt libksba openssl
brew install libyaml
install ruby:
rvm install 2.0.0 --with-openssl-dir=$HOME/.rvm/usr
if you have error
rvm install 2.0.0 --with-openssl-dir=$HOME/.rvm/opt/openssl
install new ruby gems from website. Unpackage it then go to folder and run
ruby setup.rb
gem update --system 2.1.9
install rails (you can choose your version)
gem install rails --version 4.0.2
gem install railties
I did this, and now system is working normal again.
Create another directory and run $ruby -v, check which version is available. Now run rails new app_name. Try once after closing the terminal and restarting.
This happen to me when a require error occurred in a gem (dependency) while loading.
I entered a existing ruby application, and type:
$ rails s
wanted to start rails server here.
but it said:
Your Ruby version is 1.8.7, but your Gemfile specified 1.9.3
Actually, I had a 1.8.7, but I deleted it. And if I do:
$ ruby -v
it said:
ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-darwin11.4.2]
So I don't know how can I fix it. Can you give me a help?
If you are using rvm, run this:
$ rvm use 1.9.3
try using bundler
bundle exec rails s
I had similar problem:
$ bundle install
Your Ruby version is 2.1.0, but your Gemfile specified 1.9.3
but:
$ ruby -v
1.9.3-p484
$ which ruby
/home/malo/.rvm/rubies/ruby-1.9.3-p484/bin/ruby
I've found five answers: 1, 2, 3, 4, 5. Also it was open issue on github. However, I've resolved the problem as follows:
Got path to my bundler:
$ which bundle
/home/malo/.rvm/gems/ruby-1.9.3-p484#global/bin/bundle
Opened it to edit (or just cat it), and saw that it has invalid link to ruby in the first line:
$ cat $(which bundler)|head -n 1
#!/home/malo/.rvm/rubies/ruby-2.1.0/bin/ruby
Then I get the path to current valid ruby, and just replaced that invalid with it:
$ which ruby
/home/malo/.rvm/rubies/ruby-1.9.3-p484/bin/ruby
Of course you can also try replace it with the common form:
#!/usr/bin/env ruby
This should pick up the currently used ruby version.
I found out the reason I was getting this error was that I was shelling out to a Heroku command line program inside of my configuration files and Heroku Toolbelt comes with it's own version of Ruby.
The two solutions to that problem are to either not shell out to Heroku or use a Bundler.with_clean_env block instead of the backticks to shell out the heroku command.
Please try this:
1. Open your gemfile
2. Specify rails version
3. Run bundle update
4. Run rails server - rails s
Every now and then this happens with me. However I often don't like switching ruby versions here and there. So instead what I do is I just go to the Gemfile and switch the ruby version to the one that I am using. Doing this allows me to fire up my server and keep working on things.
so for instance, right now for the app i'm working on, my Gemfile is at
ruby ENV["CUSTOM_RUBY_VERSION"] || "2.1.6"
and I would just alter it to
ruby ENV["CUSTOM_RUBY_VERSION"] || "1.9.3"
I just installed rvm + rails 3+ on centos 6.0 at Rackspace cloud server. Everything works fine, but sometimes when i ssh to server i can't use rake, bundle or any other rails related commands it always shows me errors like:
bash: rake: command not found
when i try to run bundle install it shows me this error:
ERROR: Gem bundler is not installed, run `gem install bundler` first.
but i do have it installed for sure and it worked before.I can use rvm rake db:migrate - but it used to without rvm prefix...Please help i dont know why is that happening - maybe something wrong with bash profile...
have you used a ruby ?
rvm use 1.9.3
this will select properly environment and make all commands working properly.
to make this setting permanent for new sessions also use:
rvm use 1.9.3 --default
Recently I installed jruby and put it in my home directory. This apparently hijacked rake:
$ which ruby
/usr/bin/ruby
$ which rake
/home/user/jruby-1.5.5/bin/rake
Which seemed to be causing problems. So I moved the jruby folder and reinstalled rake, which at first seemed to fix it:
$ which rake
/usr/bin/rake
But when I run rake it's still trying to use the one in jruby:
user#user-desktop:~/rails/appname$ rake db:migrate
bash: /home/user/jruby-1.5.5/bin/rake: No such file or directory
How do I fix this?
Try RVM. It is invaluable for isolating different Ruby versions. Once installed do
rvm install jruby
That gets you a separate environment for running JRuby. You can switch between versions with
rvm system
rvm jruby
I'm running a crontab that executes a rake task. I'm getting the following error (with MAILTO from crontab):
rake aborted!
no such file to load -- bundler
/Users/Mendel/Sites/misnooit/Rakefile:4
(See full trace by running task with --trace)
I'm using rvm with:
ruby: ruby 1.9.1p378
rails: Rails 3.0.0.beta
$GEM_HOME: /Users/Mendel/.rvm/gems/ruby-1.9.1-p378
bundler: bundler (0.9.11)
The error is pretty self explanatory but I'm not able to fix it.. Is there someone with more knowledge about this matter? Thanks in advance.
I just experienced this. Problem for me was that the instances of rake and ruby I use were built locally, and installed to /usr/local/bin. There are other versions in /usr/bin (must check what I installed using apt-get in the past..).
So, in my crontab file I set the path using
PATH=/usr/local/bin:/usr/bin:/bin
(I was seeing it as PATH=/usr/bin:/bin in the failed crontab emails)
and it works.
Just guessing: is Ruby 1.9.1p378 your default Ruby?
I think it's not so you can just execute rvm --defaults "ruby-1.9.1-p378"
If this doesn't help, are you sure bundler has been installed when ruby 1.9 was used?
Also, in your test/production environment, you may want to run you cron with another user than yourself. So I suggest you install rvm as "root", and set up (still as root) a default RVM that will be the default for all the system users.
And of course, you can override this per user.
I've had good experience using http://github.com/javan/whenever
It uses a Ruby DSL to manage cron tasks and it handles setting all the environment magic.
every 3.hours do
runner "MyModel.some_process"
rake "my:rake:task"
end
have your run the command with --trace asserted to ensure there isn't something obvious in the rake command, but what you could do is chain the crontab commands
rvm 1.9.1;rake do_whatever_task
That way it will load the ruby environment every time prior to running rake.
I had a similar issue this weekend, I found that my Rake Gem was updated to 0.90 you need rake 0.8.7. This solved the issue on my end.