Rails app is deployed and on, but bundle not seeing rails - ruby-on-rails

I use Rails 4 in my app and am deploying it using Ansible&Capistrano.
As an Ansible template I use playbook pretty similar to this one - https://github.com/JohnnyR1co/fashcards/blob/master/config/provision/playbook.yml
It installs ruby as well as anything else and After cap production deploy I am able to see app on (I can load some non-db related pages).
But when I try to run something like RAILS_ENV=production rails c from the current folder I get
The program 'rails' can be found in the following packages:
* ruby-railties-3.2
* ruby-railties-4.0
Try: apt-get install <selected package>
Why is this so? App is up and running, so rails seem to be fine.
Also when I try to run bundle install I get an error that nokogiri is not installed, despite I installed it manually after deploy. What could be the reason here?
I believe problem could be in playbook.ymlfile. Ruby installation is done there and I am not sure how correct is it.

This will do
bundle exec rails c production

Related

copies a rails app to a new computer: rails command not found

I have just set up ruby and rails on a freshly installed freeBSD. It works great. I can do rails new blabla mv into blabla and do rails s and it just works.
I had an up and running rails app on another computer. I copied the repertory that contained the app to the new computer running freeBSD. However, when I mv into that repertory of the rails app and to rails server I get -bash: rails: command not found
I have tried creating a new app with the same name and let rails create all the repertories and then copy the files of the existing rails app therein but no success.
I can run rails -v and rails s from within any repertory and get correct answer, but when I move into that specific repertory I get that command not found.
You're probably using a ruby version manager I suspect (rbenv/rvm)? Check the ruby version in your Gemfile (top of the file). It probably isn't the same as the ruby version you have installed. If you're using one of the above mentioned version managers than install the correct ruby for your rails project. After that you can do a gem install bundler in the project directory and after run bundle install which will install rails and all dependencies.
Which version you are using? It happens with earlier versions. Try updating your gems and bundler. And try again. Hope it helps.
Did you try running bin/rails s? I think tha you need run bundle install too.

'rails c' doesn't work, but 'bundle exec rails console' does

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.

rails installation dosn't work - can't check version

Hi I have installed passenger modul for apache2 and then i tried to install rails, with the command:
gem install rails
It seemed to be done well. But when I check the verison now with
rails --version
i got an error during this:
command not found....
You need to specify the PATH variable to folder where you have installed Rails, so when the 'rails' command will be triggered your system will know which program to launch.
Example: PATH=$PATH:/your_rails_folder

How to clone and run another user's Rails app

I'm attempting to do something I've never done before: clone another user's (codeforamerica) repository and run it locally on my computer with the intention of making my own changes to it.
I've managed to fork it to my own repositories, and cloned it:
git clone https://github.com/martynbiz/human_services_finder.git
...but when I do the following straight out the box:
cd human_services_finder
rails s
...it tell me:
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
...however, if I go into one of my own apps and run rails s it runs the server OK. Is there something missing I need to run this as a Rails app? Sorry, bit of a beginner with this one. Thanks
Below are the setups to run Ruby on Rails application on your system.
Make sure Ruby is installed on your system. Fire command prompt and run command:
ruby -v
Make sure Rails is installed
rails -v
If you see Ruby and Rails version then you are good to start, other wise Setup Ruby On Rails on Ubuntu
Once done, Now
Clone respected git repository
git clone https://github.com/martynbiz/human_services_finder.git
Install all dependencies
bundle install
Create db and migrate schema
rake db:create
rake db:migrate
Now run your application
rails s
You need to install all the dependencies (Gems). This should be possible by running
bundle install
from the applciations directory.
If you are not using RVM yet I would strongly recommend doing so.

Rails Server Won't Start

I'm trying to start my rails server with "rails server". I am getting the following error.
Could not find rake-0.9.2.2 in any of the sources
Run bundle install to install missing gems.
when I use gems, it say it is updated. Am I missing some type of path?
I am using MAC OSX Lion with the newest version of Ruby, Rake, Rails.
Run bundle install to make sure all the bundled gems are installed and available to the project.
Then try starting the server with bundle exec rails server - it's possible you've got the rake gem installed at the system level at a slightly different version level than what rails want. If you run rails via bundle exec, it'll set everything up for you

Resources