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.
Related
I was working on a project earlier today when suddenly my rails commands stopped working. I know that I must have introduced something that created an error but for the life of me I don't know what. The error that I get whenever I type any rails commands (for example, rails c, rails s, rails -v etc) is the following:
Traceback (most recent call last):
1: from /Users/mccoleman/.rvm/gems/ruby-2.5.1/bin/rails:23:in `<main>'
/Users/mccoleman/.rvm/gems/ruby-2.5.1/bin/rails:23:in `load': cannot load such file -- /Users/mccoleman/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.3/exe/rails (LoadError)
The following is my gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.2', '>= 5.2.2.1'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# 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', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
gem 'rspec'
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem 'rack-cors'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'listen', '>= 3.0.5', '< 3.2'
# 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'
gem 'rb-readline'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
I've tried searching for similar errors but haven't been able to find anything that looks similar. Any ideas why rails suddenly isn't working?
Take a look at RVM's gemset. Set a gemset for your project, use it, install and run bundle.
$ cd myproject
$ rvm create gemset mygemset
$ cat 'mygemset' > .ruby-gemset
$ cat 'ruby-2.5.1' > .ruby-version
$ cd .
$ gem install bundle
$ bundle
.ruby-version and .ruby-gemset allow RVM to set your Ruby version and gemset automatically when you cd to you project.
While I'm still not 100% sure what caused the error to occur, I was able to rectify it by uninstalling and then reinstalling 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!
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.
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 "=>").
I'am fairly new in Ruby and terms of deploying app through remote tools. I've tried to deploy my App on free openshift account. And I connot run application.
When I run application i get this error:
You have already activated rack 1.5.2, but your Gemfile requires rack 1.6.0.
Using bundle exec may solve this. (Gem::LoadError)
So I try to run bundle exec but i got another error:
Gemfile syntax error:
/var/lib/openshift/xxxxxxxxxxxxxxxxxxxxxxxxxx/app-root/runtime/repo/Gemfile:24:
syntax error, unexpected ':', expecting $end
gem 'sdoc', '~> 0.4.0', group: :doc
I think it might be because I used Ruby 2.1.5 on local and Open shift runs Ruby 2.0 by default.
I had foud this topic How can I force a bundle install on OpenShift Online when my RAILS_ENV is set to development?
but i don't know if I am doing it right. I don't even know where to put this pre_build file. I tried to put it under /var/lib/openshift/xxxxxxxxxxxxxxxxxxxxxxxxxx/app-root/runtime/repo/.openshift/action_hooks/ . But I'm not sure if runtime is right repo.
EDIT 1:
This it my Gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# 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/sstephenson/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.
group: :doc do
gem 'sdoc', '~> 0.4.0'
end
# 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'
# 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]
SOLUTION:
As #Rajarshi Das said I had to change
gem 'sdoc', '~> 0.4.0', group: :doc
into
group: :doc do
gem 'sdoc', '~> 0.4.0'
end
I don know exactly why. Maybe some syntax issues as I was using Ruby 2.1.5 on local, and had to use 2.0.0 on production. And after that I had to run gem install rails even though I used rails quick start. Finally I had to manually add to Gemfile gem 'nokogiri'. Finally I could run bundle install and application started to work.
You can simply solve the error by following way
group :doc do
gem 'sdoc', '~> 0.4.0'
end
For platforms
platforms :jruby, :mingw, :mswin do
gem 'tzinfo-data'
end
Remove Gemfile.lock as You have already activated rack 1.5.2, but your Gemfile requires rack 1.6.0
Then check bundle install
I ssh to $app_root directory
gem install rack
it worked
Make sure your branch is being used for deployment
rhc app-configure --deployment-branch [BRANCH]
Then in your development environment update gems
# bundle install
It will change Gemfile.lock
$ git add -A
$ git commit -am "Updating gemfile"
$ git push
Wait until deployment is updated
I tried most of the solutions here, but I still got stuck. What the problem was is to install bundle for the current version of ruby being used. You will want to do a gem install bundler in app-root/runtime/repo.
Then RAILS_ENV=production bundle exec rails console
You can refer to this answer