I don't know why but when I run rake commands in my rails project, nothing happens. Also rails server does nothing. Any suggestions?
you can add an "ruby -rtracer" to the begining to see where it is hanging.
The solution for me entailed exiting rails console -sandbox.
I think sandboxing console puts a lock of some sort on the database.
You could try adding the --trace argument to your rake calls to see if that sheds any light on where it is getting stuck. Failing that there may be some information in the logs.
It does suggest that something that is getting stuck during setting up your environment which may be something you've added to environment.rb.
Are you using rvm?
A lot of advice these days is to install ruby within rvm and rails within an rvm gemset. If you've done this, then you need to remember to do commands such as these at the start of your terminal session:
rvm use 1.9.3
rvm gemset use ruby193rails3
I found if I forgot to do this, then the rake command, even just a simple rake --version , would hang and thrash the disk.
...which all seems a bit fragile. I guess it's latching onto part of rails but with some files missing due to rvm not having moved them into place or something.
Spring has a bug in Rails 4.1 which also causes this (not the OP's issue, based on date). For those googling, I solved this problem my typing "spring stop". Spring will be automatically restarted the next time you run "rails ". To give proper credit, I found this information from this blog:
http://www.dixis.com/?p=754
What fixed this for me was running
bin/spring stop
and then running my rake command after.
Related
I am trying to setup a rails project and I have to use the rake db:create command to create a database. However using this command causes a Segmentation Fault bug with this error:
/home/steven/.rvm/gems/ruby-2.2.1/gems/json-1.8.3/lib/json/ext/parser.so: [BUG] Segmentation fault
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
However when I run the command bin/rake db:create I do not get a segmentation fault. I have googled and could not find the reason for this, does anyone know what the cause of this problem is? Is this a serious problem?
After further testing, this seems to be a problem with the rake command. Still not sure what is causing this.
EDIT
Running the which -a rake command gives
/home/steven/.rvm/gems/ruby-2.2.1/bin/rake
/home/steven/.rvm/rubies/ruby-2.2.1/bin/rake
/usr/local/bin/rake
Running the which ruby gives
/home/steven/.rvm/rubies/ruby-2.2.1/bin/ruby
EDIT: This page looks like it has the answer: you need to reload/reinstall ruby.
Issue with json 1.8.1 gem in rails app on production
From what you've said above, I can see that you're using rvm. It looks like the gemset for the default rake is ruby-2.2.1, but there's an error involving ruby 1.9.3p484. That's a problem
Let's assume you want to use ruby 1.9.3p484 for your project. From the project directory, run rvm use 1.9.3p484 and it should switch the PATH variable to set things right.
To see more details about which rake executable you're using, and what's available, and the order of directories Ubuntu searches for a rake executable, you can use
which -a rake -> list all possible rake executables on your PATH
echo $PATH -> show the PATH variable, which has all the directories Ubuntu searches
which rake -> show the rake used by default
Now, the reason bin/rake db:create works is because it's the right version of ruby. To set things right, you need to do the rvm use command.
For me, the correct rvm gemset is automatically switched to when I cd to the rails directory. I forget exactly how this works on Ubuntu, but I do know one clue: you need to be in a login shell. You can type su - steven to switch to a login shell, but in the Gnome Terminal preferences there's probably something about making sure you're in a login shell.
If you're already in a login shell but it's not working, you could also add
export PATH=/home/steven/.rvm/rubies/ruby-1.9.3p484/bin:$PATH
to the /home/steven/.bashrc and/or the /home/steven/.bash_profile file (I can never remember which).
There are a lot of reasons why this wouldn't work though, so feel free to comment with more details or update your question and I'll see if I can offer more ideas.
- List item
Alright, well I'm trying to fix this problem again. I followed this fix to eliminate the error by reverting to version 0.8.7, which worked the first time. However, now I'm trying to use cucumber and I'm getting it all again.
I tried it again by running gem uninstall rake -v=0.9.2.2 which lists all the gem dependencies. Successfully uninstalled. Then I ran bundle update rake. Using rake (0.8.7). Cool. rake -V. rake, version 0.9.2.2. wat. Same problems return. What am I missing? I thought 9.2 was supposed to fix this bug anyway?
I think this fix is obsolete. Rake 0.9.0 got fixed, and 0.9.2.2 is certainly working. You want to uninstall and completely eradicate rake 0.8.x. Try something like:
gem list -d rake
The -d switch will show the installation directories. If you're using RVM, there may be multiple search paths that get hit, running rvm info will tell you the search path and preference ordering. Depending on the system you're on, your OS may also ship with an old rake version. Try uninstalling everything other than the local gemset (if using RVM) or the latest rake (if not using RVM).
The problem with the rake gem uninstall sounds like you have Rake in your default gemset, check ~/.rvm/gemsets/global.gems It will no doubt have rake in it
I'm trying to setup a new rails 3 project with bundler, but i ran into issues with bundler.
I'm on rails 3.0.3 with ruby 1.8.7
When trying to do
$ bundle exec rake db:migrate
I get the following error
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/dependency.rb:52:in `initialize': Valid types are [:development, :runtime], not nil (ArgumentError)
Same goes for when I try to issue a regular rake task in my terminal, one like
$ rake -T i.e., only then I get the error:
uninitialized constant Bundler /Users/daniel/cc/contributie_data/Rakefile:4 (See full trace by running task with --trace)
I've been reading some other questions regarding this problem, therefore i've learned it has something to do with paths...
$ which rake
/usr/bin/rake
$ which ruby
/usr/local/bin/ruby
Can anyone give me some suggestions about what could be happening here?
And even more important, how I can get bundler to play nice with rake..
Thanks for any input on this, much appreciated!
I got the same error (I'm using rvm). It turned out that in both my .profile and .bashrc was the following statement:
export PATH=~/.gem/ruby/1.8/bin:$PATH
So this path was taken instead of the rvm path. I commented these lines out and now everything works fine
Try to delete Gemfile.lock. It usually helps with
Valid types are [:development, :runtime], not nil
error.
Oh man, I just when through this today.
I did an update, and my rvm broke -- started throwing up on missing scripts and the like. I just got finished completely reinstalling rvm and my rubies.
it's not great, and it takes a while but it's what I did to get back to a working state.
Started here. How can I remove RVM (Ruby Version Manager) from my system? Ended up going through and installing fresh.
I too face the same issue and resolved it with the help of this link github:bundler
Modified a line in the file lib/bundler/resolver.rb which is reside inside bundler gem. Remove * mark from the line d = Gem::Dependency.new(base.first.name, *reqs)
like this:
reqs = [dep.requirement.as_list, base.first.version.to_s].flatten.compact
d = Gem::Dependency.new(base.first.name, *reqs)
to
reqs = [dep.requirement.as_list, base.first.version.to_s].flatten.compact
d = Gem::Dependency.new(base.first.name, reqs)
*modifying content of a gem directly is not a good practice. Posted this just to show another way to resolve this issue.
I'm deploying a rails application using Capistrano to a shared server (on WebFaction). This means there are several different Ruby version installed there.
Everything works fine until I want to run some rake tasks. These tasks fail by saying I don't have the right RubyGems version.
From this thread I understood that fixing it would be as easy as adding the full path to the correct rake folder to my rake commands. I tried that but failed again, now because the Ruby interpreter that is used is the wrong one.
I assumed that capistrano would use the username/password I gave it to run commands on the server but it seems not to be the case.
Am I missing something? How can I fix that?
Thanks!
This is indeed a path issue. I solved it by symlinking my ruby, rake, and rails executables to my path. For instance, if the executables that you want (but are failing to work) are located at /opt/ruby/bin/ruby, you'll symlink it to:
ln -s /opt/ruby/bin/ruby /usr/local/bin/ruby
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.