rails server command is not working "using weBrick" "rails" - ruby-on-rails

I have searched or similar problems , but none of the solutions worked for me .
I will describe the problem in details:
The server works as normal when i create a new rails app , our instructor have told us to replace the existing gem file with another -shown below- and run bundle or bundle update to resolve the gems
source 'https://rubygems.org'
gem 'rails', '4.2.3'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'therubyracer', platforms: :ruby
gem 'capybara', '~> 2.4.4'
gem 'poltergeist', '~> 1.6.0'
gem 'phantomjs', '~> 1.9.8.0'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'spring'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'httparty'
The problem appear when I do replace the existing gem file with the new one ,the server don't work and here is my command line logs.
if you need any further information, leave a comment.
edit: more info >>>rails version installed 5.0.1

I have found a solution for the problem , and I want to leave it here ,so anyone have the same problem could use .
The problem was that I had rails v5.0.1 installed , and that caused problems related to comparability with other gems , so I downgraded my rails to 4.2.3
1-first you need to run gem uninstall rails ,and gem uninstall railties
2-now , go ahead and install rails again ,you could search for rails 4.2.3 to download and install it or you could do this through the command , I'm working on windows and I don't know how the command looks on others ,but I believe it's something similar , you could try this gem install rails '4.2.3' and that it!

Related

rails cannot find gems even after bundle install

I am currently trying to start my rails server after doing a bundle install. However, when I try to do rails s, this error pops up
Could not find gem 'byebug (= 9.0.6)' in any of the gem sources listed in your Gemfile. Run bundle install to install missing gems.
I then run bundle install but the same error pops up. I've also tried getting rid of byebug in the gemfile but it just gives me the same error but with a different gem. I've tried installing byebug individually using gem install byebug -v 9.0.6 but the same problem persists.
This is my gemfile
source 'https://rubygems.org'
gem 'rails', '5.1.6'
gem 'puma', '3.9.1'
gem 'sass-rails', '5.0.6'
gem 'uglifier', '3.2.0'
gem 'coffee-rails', '4.2.2'
gem 'jquery-rails', '4.3.1'
gem 'turbolinks', '5.0.1'
gem 'jbuilder', '2.7.0'
group :development, :test do
gem 'sqlite3', '1.3.12'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', '9.0.6', platform: :mri
end
group :development do
gem 'web-console', '3.5.1'
gem 'listen', '3.1.5'
gem 'spring', '2.0.2'
gem 'spring-watcher-listen', '2.0.1'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
You should run your rails server with bundle exec rails s to be in the context of the bundle.
In my case, there was a following line in .bundle/config
BUNDLE_WITHOUT: "test:development"
After removing that line and running bundle install, everything works fine.

Rails 5: rails s vs. bundle exec rails s

I'm starting a project on Rails 5 for the first time and I was curious why running 'rails s' when I was on Rails 4 worked fine, but now that I'm on Rails 5 I need to preface it with 'bundle exec' in order to run the command properly.
Below is my Gemfile. Again, everything works normally if I preface all my rails commands with. I'm just curious if anyone else experiencing this or if someone can give me some insight as to why this is happening?
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.18'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'bootstrap', '~> 4.0.0.alpha3'
source 'https://rails-assets.org' do
gem 'rails-assets-tether', '>= 1.1.0'
end
gem "paperclip", "~> 5.0.0"
gem "browser"
# Use Capistrano for deployment
gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console'
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
It sounds like the rails command you have installed globally is rails 4 and it's the reason "it doesn't run properly" like you say. When you run bundle exec then it uses the rails commands from the current Gemfile, since you have rails 5 in your Gemfile then it works properly.
I'd recommend using either RVM or rbenv, I personally like RVM since it switches automatically to the gemset of the ruby version specified in my Gemfile.
Example, when I cd into the directory of my project I get a message like:
RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too.
Using bundle exec guarantees that the program is run with the environment specified in the gemfile, which hopefully means it is the environment that the creators of the program want it to be run in, which hopefully means it should run correctly no matter what weird setup you have on your computer.
Reference: Use bundle exec rake or just rake?

Could not find gem 'rails (= 4.2.4) x64-mingw32'

I was first developing my RoR application in Windows. Now since I've been founding a few problems regarding some gems, SSH and stuff I decided to move to Linux. I am trying to initate the application, but It seems I am not able to.
When I do bundle update rails I got the following error:
Could not find gem 'rails (= 4.2.4) x64-mingw32' in the gems available on this
machine.
This is my tzinfo-data gem:
gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
But I have already tried with this one too:
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Any idea? Because when I just do bundle install I also got the following error:
You have requested:
rails = 4.2.4
The bundle currently has rails locked at 4.2.4.
Try running `bundle update rails`
Update:
Gemfile content
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'bootstrap-sass', '~> 3.2.0'
gem 'autoprefixer-rails'
gem 'devise'
gem 'bootstrap_form'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
gem "bcrypt-ruby", '~> 3.0.0'
gem 'google-api-client', '0.9'
gem 'letsrate'
gem 'will_paginate', '~> 3.0.6'
gem 'filterrific'
#gem 'ratyrate'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
If you’ve installed Rails using bundler and rubygems, make sure you have the latest version in your Gemfile:
rails '4.2.4'
there is Gemfile.lock which locks the version. You delete that and run again bundle install. it will work.
bundle install
Visit https://rubygems.org/gems
Search for your gem. Once found, copy the text from the box titled GEMFILE
Add the copied text in your Gemfile found inside your app
Run bundlefrom the console opened at the root of your app.
On successful installation of the gems your console will display the message:
Bundle complete! xx Gemfile dependencies, xx gems now installed.

Could not find gem 'rails (= 4.2.5) x86-mingw32' when running rails server

I'm trying to learn Ruby on Rails.
Currently been trying out Rails framework. I've installed it. Create new project in MyBlog folder, but when I try to run:
rails server
I get back an error:
Could not find gem 'rails (= 4.2.5) x86-mingw32' in any of the gem sources listed in your Gemfile or available on this machine. Run `bundle install` to install missing gems.
I've installed bundle as suggested. Had few problems with installing it as well, but I've found a soultion on the internet.
Before bundle install I was getting another error saying that it could not find gem 'sqlite3'
Did someone had similar problem? Can you help me with solving it?
Update:
Content of my Gemfile is:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Errors when try to run 'bundle install':
Try to install the following packages to succeed bundle install
sudo apt-get install build-essential
sudo apt-get install libgmp3-dev
These packages are for Linux environment. Find the alternatives for other environments. Let me know if you got any error.
open file Gemfile.lock, find and delete "x64-mingw32" then run the command:-
$bundle install
Late answer but this happened to me just now.
What worked for me was figuring out I accidently installed an older Ruby version.
In your last screenshot you received a line:
Make sure that `gem install json -v '1.8.3'` succeeds before bundling
This command probably failed due to an older Ruby version, get the latest version here (Assuming you're a windows user) https://rubyinstaller.org/downloads/
P.S
Make sure you remove any previous Ruby / Rails installations.
What you need is a "With DEVKIT" installer, preferably the one they recommend on (starts with "=>").

Error trying to get rails server running in windows command prompt

I've been developing a (very simple) Rails project and have moved the files to a new machine. I have Ruby (version 2.0.0p195) and Rails (4.0.0) installed.
From the C:\Sites directory in command prompt (console), when I type 'rails server' I get a whole bunch of information that starts with:
Usage:
rails new APP_PATH [options]
...
...and continues with Options:, Runtime options:, Rails options: and so on.
When I cd to the directory of my copied project:
C:\Sites\elearning
and try 'rails server' I get the following error:
'mri_21' is not a valid platform. The available options are: [:ruby, :ruby_18, :ruby_19, :ruby_20, :mri, :mri_18, :mri_19, :mri_20, :rbx, :jruby, :mswim, :mingw, :mingw_18, :mingw_19, :mingw_20]
Does anyone know what I'm doing wrong? Is it possible to copy a rails project from another computer? And if so, how would I do that?
Any help, much appreciated.
Edit:
FYI, my gemfile is as follows:
source 'https://rubygems.org'
ruby '2.1.2'
gem 'rails', '4.1.5'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'bootstrap-sass'
gem 'devise'
gem 'sqlite3'
gem 'thin'
group :development do
gem 'better_errors'
gem 'binding_of_caller', :platforms=>[:mri_21]
gem 'quiet_assets'
gem 'rails_layout'
gem 'byebug'
end
For those trying to transfer a mac project to PC: I've finally got rails server running.
First, in the gem file, I changed the reference 'mri_21' to 'mri_20' and changed the ruby version number to match my version of ruby.
I had other errors, but the short story is that I created a new rails project, copied MOST of the old project files into the corresponding files of the new project and EVENTUALLY noticed the comment at the bottom of the new (freshly created) routes.rb file:
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
So I added:
gem 'tzinfo-data', platforms: [:mingw, :mswin]
and all is, for now, right with the world.
So, if you're transferring a mac project to PC, you'll need to add the tzinfo-data gem to your gemfile.
Try running "gem update bundler" and see if that works.

Resources