How to clone and run another user's Rails app - ruby-on-rails

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.

Related

"rails new" is not generating any of my project's folders

I have downloaded Ruby, and installed the rails gem, then I attempt to run rails new my-project and all I get is this:
c:\Projects>rails new my-project
create
create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create Gemfile
run git init from "."
When I open the my-project folder that rails created for me what I find in it is only:
.gitignore
.ruby-version
config.ru
Gemfile
Rakefile
README.md
and nothing else.
This is not what I got when testing this at home, and it's not what any guide says I should get. I have exactly zero folders generated by rails, it's nowhere near what I need to start development. I don't think I'm missing any installations. Here are the versions of ruby and of rails:
c:\Projects>ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x64-mingw32]
c:\Projects>rails -v
Rails 6.0.2
IIRC I installed Ruby using the Windows Ruby Installer at rubyinstaller.org, the latest version with Devkit, then I simply ran gem install rails to get Rails.
The only thing I can think of is that my user does not have admin privileges in this computer, but when I try to Google if this is a requirement, all Google gives me is how to implement admin stuff in my app.
Try appending --skip-git to your rails new command. This will get you going in the short term.
Alternatively (and probably the better option in the long run), install git. The official Git documentation install instructions can be found here: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
I have the same issue. Thanks to Scott Schupbach answer I realize that I didn't Install git, because I was working in a fresh ubuntu 19.10 installation.
So for anyone with the same issue, just install git.
In Ubuntu (or other Debian-based Linux distribution) just type:
sudo apt install git
On Mac (using Homebrew):
brew install git
For Windows, non-Debian Linux systems, and alternative Mac installer options, see the official Git installation documentation: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
And that's all.
Best Regards!!
uninstall rails
delete the project folder
install git with sudo - "sudo apt install git"
reinstall rails - "gem install rails"
create the project folder again and do the cd command to be in the new folder
Run the command again- "rails new [project name]"
Facing this issue as git was not installed on system.
Try to run below command to install git
sudo apt install git
And then create a new rails project with rails command
rails new myApp
It will create complete folder structure for you

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 app is deployed and on, but bundle not seeing 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

'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.

using github for windows can't start rails server after pulling a repo

I added some collaborators to a rails project on github. They pull down the project using github for windows but then cannot start the rails server
rails server gives them the same output as typing rails
When we do ls we get:
From the Github directory I tried chmod -R 777 sindika but it didn't work. Why can't they pull down the project and start the server?
Seems like the version of your globally installed rails gem is different from the one the project is built on, so Rails don't recognize this folder as its project. Doing bundle && bundle exec rails s should do the trick. Another way to solve this would be to uninstall the current version of the Rails gem and install the one that corresponds to your project.

Resources