I am trying to run rails console using bundle exec rails c command. But console is not opening. I have not installed ruby or rails using apt, instead using rvm and gems respectively.
But when i ctr + c to terminate command i get some error as below
/mypath/vendor/bundle/ruby/2.6.0/gems/mysql2-0.5.2/lib/mysql2/client.rb:90:in
connect: Interrupt
I am not able to understand exact error.
Related
I added the gem cancancan, ~> 1.10 to my gemfile and then ran bundle install.
That all went well but then I get the following in my terminal when I run > rails g cancan:ability:
Running via Spring preloader in process 967 Could not find generator 'cancan:ability'. Maybe you meant 'coffee:assets', 'channel' or 'css:assets' Run rails generate --help for more options.
I tried running the command spring stop and then ran rails g cancan:ability and I get the same message.
Any ideas? Thanks for the help.
I'm setting up the staging and production server on Ubuntu, deploy with Capistrano. Both server has pretty much the same setup. But for for some reason. I can access console on production server with rails c produciton. But when I try to access console on staging server using rails c staging
The program 'rails' can be found in the following packages:
* ruby-railties-3.2
* ruby-railties-4.0
Try: sudo apt-get install <selected package>
The only way to access console on my staging server is to do
bundle exec rails console staging
On staging
the rvm seems to be correct, I can see the ruby version I'm using.
the gemset that the application use is there.
the application is running fine. Just can't access console with 'rails c'
But for some reason, I can't access console with rails c. Any idea how to solve this issue?
I guess you didn't install rails globally. First, check your rails version you are currently using by bundle exec rails -v. Then, install rails globally by gem install rails -v <version>. This should solve your issue.
Run bundle install only makes rails available inside bundler. In most cases, this should be enough, because bundler helps prevent headaches of version conflicts.
A couple of questions to understand better the situation...
Have you tried running bundle install for the current ruby version set on rvm for that application on that server?
Have you updated the gems for another application/branch? sometimes that happens because the rails c command uses the latest gems available and bundle exec... locates and uses the gems tied to the Gemfile.lock.
The application should run fine because it uses the gems that the Gemfile.lock has listed.
I use AWS with Elasticbeanstalk to deploy my applications, but I can't run the command rails console once ssh to my server and going to /var/app/current.
I tried many commands, without success :
bundle exec rails c
RAILS_ENV=development rails c
I got the follow error:
Could not find addressable-2.3.6 in any of the sources
Run `bundle install` to install missing gems.
But when running bundle install everything is fine.
This error is a huge issue to me as I can't use the whenever cron job.
Can you help me ?
PS : Gist of my Gemfile here
ran into similar problem and this is what solved my problem:
you may try sudo gem install bundler from your root and later move to app/current and try run rails c -e environment_name
Despite answers like these: rails s or bundle exec rails s
and blog posts like these: https://www.wyeworks.com/blog/2011/12/27/bundle-exec-rails-executes-bundler-setup-3-times/
which all seem to indicate you should simply run rails s rather than bundle exec rails s I still find that occasionally I can't simply run rails s. E.g.
$ rails s
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
Whereas running this immediately afterwards in the same environment:
$ bundle exec rails s
=> Booting WEBrick
=> Rails 4.0.0.beta1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2015-01-28 12:31:48] INFO WEBrick 1.3.1
[2015-01-28 12:31:48] INFO ruby 2.0.0 (2014-11-13) [x86_64-darwin14.0.0]
[2015-01-28 12:31:48] INFO WEBrick::HTTPServer#start: pid=18959 port=3000
Why is it not the same? Should this behaviour be fixed and, if so, how?
==== UPDATE
In response to #awendt
$ which rails
/Users/snowcrash/.rvm/gems/ruby-2.0.0-p598/bin/rails
$ rails c
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
$ bundle exec rails c
Loading development environment (Rails 4.0.0.beta1)
2.0.0-p598 :001 >
Trying to reproduce this, I get (on Ubuntu 12.04.5 LTS):
me#machine:/some/path$ rails c
The program 'rails' is currently not installed. To run 'rails' please ask your administrator to install the package 'rails'
me#machine:/some/path$ which rails
me#machine:/some/path$
So in my case, the rails script is not in my $PATH.
Your setup is different because the message explicitly mentions gems. You might even get this:
you#machine:/some/path$ which rails
/usr/bin/rails
you#machine:/some/path$
because /usr/bin/ is in your $PATH somewhere before other things and you're still invoking the rails script that ships with the OS.
Anyway, the important part is: bundle exec rails c lets Bundler figure out where to find the Rails gem, instead of letting the shell figure it out.
You may install gem into a completely arbitrary location, where only Bundler can find them because that location is not in your $PATH but in your $BUNDLE_PATH (see list of available keys for bundle config).
That's why rails and bundle exec rails are not the same.
This is not an error, and the behavior should not be fixed. Yes, you shouldn't have to run bundle exec rails because in recent versions, rails does the exact same thing. But the error you're seeing is a different issue.
For Rails 3x and above,whenever you are running the rails server,its always in context of the your environment and your Gemfile.So bundler helps in this regards to start and load the required gems/libraries using $BUNDLE_PATH for starting the application which by default wont be there if your are not using bundle exec instead it includes only the default libraries/gems using gemset(if you are using rvm) OR default path to load.
..hope this helps
I've installed rails using rvm and everything works well in the out of the box terminal using zsh. I thought i'd simplify things a bit and bring out Coda's terminal but for some reason when I run
$ rails --version
I get errors saying there are missing dependencies or when using $ rails new new_app Coda terminal tells me that rails isn't installed. running $ gem list and $ gem environment give me the same output in both terminals.
you need to load rvm before using it
load rvm script with
source ~/.rvm/bin/rvm