Rails from directory of application doesn't work - ruby-on-rails

I have installed rails.
Once installed I create a application with
$ rails new my_app
and I ran the rail server from the directory of the application.
~/rails_projects/my_app$ rails server
The problem is that after exiting the application when I go to that directory later I can't run the server this second time.
~/rails_projects/my_app$ rails server
Could not find gem 'spring (>= 0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
It doesn't show any Rails version from that directory but yes from the home directory:
~$ rails -v
Rails 4.1.1
~/rails_projects/my_app$ rails -v
Could not find gem 'spring (>= 0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems

It seams you are starting with Rails. Please follow the official guide to get an inside of the framework.
To get started you need to create a project:
$ rails new my_app
then go the project directory:
$ cd my_app
install dependencies (if you add any to your Gemfile):
$ bundle install
and then run the server
$ rails server
Again, if you are starting follow that guide!

Related

Can't run rails -v in proejct folder on ubuntu 20.04 server

Ruby version: 3.1.0
Rails version: 7.0.4
RVM 1.29.12
Ubuntu 20.04
It is a digital ocean droplet
I have SSH'ed into an ubuntu 20.04 server.
I have installed rvm and rails.
If I stand in the rails user folder and write rails -v it gives me the rail version.
If I go into a project folder and try the same thing it just says.
Could not find rails-7.0.4, sprockets-rails-3.4.2, puma-5.6.5, importmap-rails-1.1.5, turbo-rails-1.3.2, stimulus-rails-1.1.0, jbuilder-2.11.5, bootstrap-5.2.2, simple_form-5.1.0, ransack-3.2.1, bootstrap-select-rails-1.13.8, jquery-rails-4.5.0, sqlite3-1.5.3-x86_64-linux, sprockets-4.1.1, sassc-rails-2.1.2, sassc-2.4.0, tilt-2.0.11, ffi-1.15.5 in locally installed gems
Run `bundle install` to install missing gems.
Running bundle install ends with the text "Killed"
My bundle config is
---
BUNDLE_DEPLOYMENT: "true"
BUNDLE_WITHOUT: "development:test"
BUNDLE_PATH: "vendor/bundle"
It seems bundle install doesn't install ffi 1.15.5 correct.
Installing ffi 1.15.5 with native extensions
Killed
and it does that everytime I run bundle install
I tried to run rails -v in the rails user folder
and it gives the rails version.
If I try in the project folder
It throws an error and ask me to run bundle install.
I run bundle install and it seems to finish without issues, but it doesn't fix the problem
Try bundle exec rails -v in your project folder.
Solved it by upgrading the server to 1 gb ram instead of 512 mb

Why does my rails not run?

When I run $ rails -server to start a server, there comes an error:
Could not find gem 'sqlite3' in any of the gem sources listed in your Gemfile or available on this machine.
Does that mean I did not install sqlite3? How can I resolve the issue?
First, you have to install all Gems from your Gemfile.
This can be done with bundle install or in short bundle.
If this command executed successfully, you can run your server with rails s.
But I think it's better for you, to start with a tutorial.
server and s are not a switch, but a sub-command.
Run
$ rails server
or
$ rails s
I run into this issue previously, that is because you run bundle install, miss some gems, so you can $ bundle install again,
and you can test the sqlite if is installed:
$ sqlite3 --version
If successed, you can test the rails server.

Failed generating controller due to Bundler version conflict

I'm learning Rails with tutorials from Ruby on Rails by Michael Hartl: https://www.railstutorial.org/book
I used the following command to generate a controller:
rails generate controller StaticPages home help
Which generates the following error regarding version conflicts:
check_version_conflict': can't activate bundler-1.12.4, already
activated bundler-1.13.0.pre.1 (Gem::LoadError)
I don't know which bundler version to use. The current version of bundler is: 1.13.pre.1
The following command continued failing due to about five gem dependencies that failed to install automatically, which included listen and nokigiri.
bundle install --without production
I tried installing the dependent gems manually, but I'm still having issues.
How do I resolve the check_version_conflict issue with Bundler when generating Rails controllers?
I'll accept an answer that instructs removing current Ruby libs and installing a new development environment from scratch.
Bundler will install project-specific versions of your gems so that you don't have to manage global dependencies.
In effect, if you install Rails with bundler and you also install it with sudo gem install rails or something like that, you'll have two versions on your computer. By default, calling rails will refer to the global version.
If you call bundle exec rails (or bundle exec <gem_name>), it will call the bundler-specific version.
Ten steps to resolve your issues with Bundler
(optional) Uninstall Ruby. There are many ways to do so, here's one: https://superuser.com/questions/194051/how-to-completely-remove-ruby-ruby-gems-on-mac-os-x-10-6-4
(optional) Use rbenv to install Ruby. Follow instructions here: https://github.com/rbenv/rbenv
Make a repo directory that will house your future Rails app
From the command line:
mkdir repo
cd repo
Install Bundler and create a Gemfile for the directory
From the command line:
gem install bundler
bundle init
Open the repo/Gemfile with your editor, and configure it to instruct Bundler which version of Rails to install
In repo/Gemfile:
source "https://rubygems.org"
gem "rails", "4.2.6"
Install Rails via Bundler
From the command line:
bundle install
Create a new Rails app using Bundler, and cd into it
From the command line:
bundle exec rails new whatevs
cd whatevs
Your Rails app will have a Gemfile by default. Open it and add the gems you wish to use in your app.
In repo/whatevs/Gemfile:
gem 'nokogiri', '1.6.8'
From repo/whatevs/ directory, install your app's Gems via Bundler
From the command line:
bundle install
From repo/whatevs/ directory, generate a controller
From the command line:
bundle exec rails generate controller static_pages home help

How Do You Install Missing sass-rails gem?

Hi new to stackoverflow and Ruby on Rails in general. I'm following the Kevin Skoglund Ruby on Rails 3 Essential Training online tutorial and I'm having trouble starting out. I'm trying to boot WEBrick but each time I try I get this error:
C:\Users\Matt\Documents\Sites\simple_cms>rails server
Could not find gem 'sass-rails (~> 5.0) x86-mingw32' in any of the gem sources l
isted in your Gemfile or installed on this machine.
Run bundle install to install missing gems.
What do I do to install this missing sass-rails gem, so I can boot WEBrick?
You can certainly run bundle install in your terminal, or command line, as the output suggests.
$ bundle install
If that fails, run:
$ gem install bundler
$ bundle install

Could not find gem 'sqlite3 (>= 0) ruby'

I am learning Ruby on Rails and I followed the installation of RVM and Rails from Ryan Bigg's blog and the Agile Wed Development book. This has worked previously on my PC at home, but at work it gives me the error:
depot$ rails -v
Could not find gem 'sqlite3 (>= 0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
I am trying to generate a scaffold but this is what i get:
depot$ rails generate scaffold Product \ title:string description:text image_url:text price:decimal
Could not find gem 'sqlite3 (>= 0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.
I have sqlite3 installed, RVM 1.9.2-p320, and running on Ubuntu 11.04.
Any ideas what can be causing this and how to fix it?
Run
bundle install
in your Rails app's directory just like both error messages instruct you to.
i had the same issue you could try to run sudo apt-get install libsqlite3-dev and bundle install in the app directory.
You need to run it from your app directory so it can find the Gemfile to know which gems it needs to install from the Gemfile.
Yes. I was also having the same problem
when I started with rails, then when writing "rails new " I got this problem of sqlite3 . This appears due to the reason that "bundle install" is not executed. When we try to 'bundle install' then it will show some gemfile missing error. This happens due to the reason that we haven't changed the directory to that folder where we are using the rails application. So for solving this problem follow these steps :
type 'rails new app' // instead of app you can type any name you want.
now a folder named app will be created in your home.
now start new terminal.
type 'cd app'
now you can continue your work, and you will not face any such problem.

Resources