I fail to install rails properly for some reason. gem install rails says everything is fine but I cannot use it due to some missing gemfile. What am I doing wrong?
I am working on a mac Sierra.
$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
$ gem install rails
Fetching: rails-5.1.4.gem (100%)
Successfully installed rails-5.1.4
1 gem installed
$ rails -v
Could not locate Gemfile or .bundle/ directory
$ gem list rails
*** LOCAL GEMS ***
jquery-rails (4.3.1)
less-rails (3.0.0, 2.8.0)
rails (5.1.4)
rails-dom-testing (2.0.3, 2.0.2, 2.0.1)
rails-html-sanitizer (1.0.3)
rails_12factor (0.0.3)
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
rspec-rails (3.7.2)
sprockets-rails (3.2.1, 3.2.0)
twitter-bootstrap-rails (4.0.0, 3.2.2)
Related
I am having issues trying to solve this dependency issue. I have sqlite3 in my gemfile and I can see it installed, even when I run gem list (inside my docker container). But when I generate my dependencies with docker build, then run my project in a container, I get the following error when trying to run rake test
root#401a61839c07:/app# rake test
rake aborted!
LoadError: cannot load such file -- sqlite3/sqlite3_native
Here is the build and you can clearly see that sqlite is installed.
docker build -f DependenciesDockerfile -t visual-base .
.
.
.
Step 12 : RUN bundle install --without development
---> Running in 623d8b439808
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Installing rake 10.5.0
Installing i18n 0.7.0
Installing json 1.8.3
Installing minitest 5.8.4
Installing thread_safe 0.3.5
Installing tzinfo 1.2.2
Installing activesupport 4.1.6
Installing builder 3.2.2
Installing erubis 2.7.0
Installing actionview 4.1.6
Installing rack 1.5.5
Installing rack-test 0.6.3
Installing actionpack 4.1.6
Installing mime-types 2.99.1
Installing mail 2.6.3
Installing actionmailer 4.1.6
Installing activemodel 4.1.6
Installing arel 5.0.1.20140414130214
Installing activerecord 4.1.6
Installing execjs 2.6.0
Installing autoprefixer-rails 6.3.3.1
Installing bcrypt 3.1.11
Installing sass 3.2.19
Installing bootstrap-sass 3.3.5
Installing climate_control 0.0.3
Installing cocaine 0.5.8
Installing coffee-script-source 1.10.0
Installing coffee-script 2.4.1
Using thor 0.19.1
Installing railties 4.1.6
Installing coffee-rails 4.0.1
Installing jquery-rails 3.1.4
Using bundler 1.8.0
Installing hike 1.2.3
Installing multi_json 1.11.2
Installing tilt 1.4.1
Installing sprockets 2.12.4
Installing sprockets-rails 2.3.3
Installing rails 4.1.6
Installing commontator 4.10.5
Installing orm_adapter 0.5.0
Installing responders 1.1.2
Installing warden 1.2.6
Installing devise 3.5.6
Installing devise-bootstrap-views 0.0.8
Installing gretel 3.0.8
Installing jbuilder 2.4.1
Installing kgio 2.10.0
Installing mimemagic 0.3.0
Installing net-ldap 0.14.0
Installing paperclip 4.3.5
Installing pg 0.18.4
Installing polyamorous 1.1.0
Installing raindrops 0.16.0
Installing rdoc 4.2.2
Installing rmagick 2.13.3
Installing sass-rails 4.0.5
Installing sdoc 0.4.1
Installing sqlite3 1.3.11
Installing squeel 1.2.3
Installing turbolinks 2.5.3
Installing uglifier 2.7.2
Installing unicorn 5.0.1
Bundle complete! 28 Gemfile dependencies, 63 gems now installed.
Gems in the group development were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Post-install message from rmagick:
Please report any bugs. See https://github.com/gemhome/rmagick/compare/RMagick_2-13-2...master and https://github.com/rmagick/rmagick/issues/18
---> 901bbde8aa4f
Removing intermediate container 623d8b439808
Successfully built 901bbde8aa4f
2.2.3 in visual-automation/ on master
› docker build -t visual .
Sending build context to Docker daemon 112.3 MB
Step 1 : FROM visual-base
---> 901bbde8aa4f
Step 2 : MAINTAINER
---> Running in bd02c1f718e7
---> 02f76881207c
Removing intermediate container bd02c1f718e7
Step 3 : ADD . /app
---> 4f80ec7fccce
Removing intermediate container 6d73bdc55fde
Step 4 : RUN sed -i.bak 's/user www-data;/user root;/g' /etc/nginx/nginx.conf
---> Running in df22155ce2b7
---> aa9442d89c9e
Removing intermediate container df22155ce2b7
Step 5 : EXPOSE 80
---> Running in f839dd6707ce
---> d197974fa925
Removing intermediate container f839dd6707ce
Successfully built d197974fa925
2.2.3 in repo/ on master
› docker run -it visual /bin/bash
root#401a61839c07:/app# rake test
rake aborted!
LoadError: cannot load such file -- sqlite3/sqlite3_native
/app/vendor/cache/ruby/2.2.0/gems/sqlite3-1.3.11/lib/sqlite3.rb:6:in `require'
/app/vendor/cache/ruby/2.2.0/gems/sqlite3-1.3.11/lib/sqlite3.rb:6:in `rescue in <top (required)>'
/app/vendor/cache/ruby/2.2.0/gems/sqlite3-1.3.11/lib/sqlite3.rb:2:in `<top (required)>'
/app/config/application.rb:7:in `<top (required)>'
/app/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- sqlite3/2.2/sqlite3_native
/app/vendor/cache/ruby/2.2.0/gems/sqlite3-1.3.11/lib/sqlite3.rb:4:in `require'
/app/vendor/cache/ruby/2.2.0/gems/sqlite3-1.3.11/lib/sqlite3.rb:4:in `<top (required)>'
/app/config/application.rb:7:in `<top (required)>'
/app/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
root#401a61839c07:/app#
Here is the output of gem list when run inside the container
root#69296d7eec2a:/app# gem list
*** LOCAL GEMS ***
actionmailer (4.1.6)
actionpack (4.1.6)
actionview (4.1.6)
activemodel (4.1.6)
activerecord (4.1.6)
activesupport (4.1.6)
arel (5.0.1.20140414130214)
autoprefixer-rails (5.2.1.1)
bcrypt (3.1.10)
bigdecimal (1.2.6)
bootstrap-sass (3.3.5)
builder (3.2.2)
bundler (1.8.0)
climate_control (0.0.3)
cocaine (0.5.8)
coffee-rails (4.0.1)
coffee-script (2.4.1)
coffee-script-source (1.9.1.1)
commontator (4.10.5)
devise (3.5.1)
devise-bootstrap-views (0.0.5)
dotenv (1.0.2)
erubis (2.7.0)
execjs (2.5.2)
foreman (0.77.0)
gretel (3.0.8)
hike (1.2.3)
i18n (0.7.0)
io-console (0.4.3)
jbuilder (2.3.1)
jquery-rails (3.1.3)
json (1.8.3, 1.8.1)
kgio (2.9.3)
mail (2.6.3)
mime-types (2.6.1)
mimemagic (0.3.0)
minitest (5.8.4, 5.4.3)
multi_json (1.11.2)
net-ldap (0.11)
orm_adapter (0.5.0)
paperclip (4.3.5)
pg (0.18.3)
polyamorous (1.1.0)
power_assert (0.2.2)
psych (2.0.8)
rack (1.5.5)
rack-test (0.6.3)
rails (4.1.6)
railties (4.1.6)
raindrops (0.15.0)
rake (10.4.2)
rdoc (4.2.0)
responders (1.1.2)
rmagick (2.13.3)
sass (3.2.19)
sass-rails (4.0.5)
sdoc (0.4.1)
sprockets (2.12.4)
sprockets-rails (2.3.2)
sqlite3 (1.3.11)
squeel (1.2.3)
test-unit (3.0.8)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
turbolinks (2.5.3)
tzinfo (1.2.2)
uglifier (2.7.1)
unicorn (4.9.0)
warden (1.2.3)
I have seen temporary solutions by editing gemspecs but once you fix one, another similar error pops up. I must be missing something but it appears everything is in order.
Any help would be much appreciated
From the documentation of the ruby gem https://github.com/sparklemotion/sqlite3-ruby It says
This module allows Ruby programs to interface with the SQLite3 database engine (www.sqlite.org). You must have the SQLite engine installed in order to build this module.
I think the issue here is that your docker container doesn't have the sqlite3 engine installed, so when the gem tries to call out to the native code it can't.
Verify that you have a line like
RUN apt-get sqlite3 in your Dockerfile.
This is an update for the problem mentioned below:
I just found out that there is a Gemfile and Gemfile.lock in the root directory i.e system Home directory, and when ever i create a new gemset i believe it uses this gemfile. After installing rails in a newly created gemset, when check the rails version or try to create a new app, it shows the error Your ruby version is 2.2.0, but your Gemfile specifies 2.1.5, cause the Gemfile file in my home directory contains that ruby version, and if delete that Gemfile, and try to create a new rails app, it searches for that Gemfile.
I am current going through a hard time. I was starting a new project in ruby 2.2.0 and rails 4.2.0 and started by creating a gemset using RVM inside my project folder.
created gemset.
$rvm use ruby-2.2.0#myapp --ruby-version --create
Installed latest rails
$gem install rails
After that i checked the rails version just to verify
$rails -v
but instead i get a notification saying Your Ruby version in 2.2.0 but your Gemfile specified 2.1.5. I also don't have my application folder yet, cause i get the same output if i try to $rails new .
Following are the RVM related outputs
My RVM version is 1.26.10.
rvm gemset list
gemsets for ruby-2.2.0 (found in /Users/samy/.rvm/gems/ruby-2.2.0)
(default)
global
student-portal
=> myapp
gem list for global gemset
bigdecimal (1.2.7, 1.2.6)
bundler (1.7.13)
bundler-unload (1.0.2)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
io-console (0.4.3)
json (1.8.2, 1.8.1)
mini_portile (0.6.2)
minitest (5.5.1, 5.4.3)
nokogiri (1.6.6.2)
power_assert (0.2.2)
psych (2.0.12, 2.0.8)
rake (10.4.2)
rdoc (4.2.0)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
test-unit (3.0.9, 3.0.8)
gem list for myapp gemset
actionmailer (4.2.0)
actionpack (4.2.0)
actionview (4.2.0)
activejob (4.2.0)
activemodel (4.2.0)
activerecord (4.2.0)
activesupport (4.2.0)
arel (6.0.0)
bigdecimal (1.2.7, 1.2.6)
builder (3.2.2)
bundler (1.7.13)
bundler-unload (1.0.2)
erubis (2.7.0)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
globalid (0.3.2)
hike (1.2.3)
i18n (0.7.0)
io-console (0.4.3)
json (1.8.2, 1.8.1)
loofah (2.0.1)
mail (2.6.3)
mime-types (2.4.3)
mini_portile (0.6.2)
minitest (5.5.1, 5.4.3)
multi_json (1.10.1)
nokogiri (1.6.6.2)
power_assert (0.2.2)
psych (2.0.12, 2.0.8)
rack (1.6.0)
rack-test (0.6.3)
rails (4.2.0)
rails-deprecated_sanitizer (1.0.3)
rails-dom-testing (1.0.5)
rails-html-sanitizer (1.0.1)
railties (4.2.0)
rake (10.4.2)
rdoc (4.2.0)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
sprockets (2.12.3)
sprockets-rails (2.2.4)
test-unit (3.0.9, 3.0.8)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
tzinfo (1.2.2)
which ruby gives
/Users/samy/.rvm/rubies/ruby-2.2.0/bin/ruby
which rails gives
/Users/samy/.rvm/gems/ruby-2.2.0#myapp/bin/rails
the file contains
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'railties' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
version = $1
ARGV.shift
end
end
gem 'railties', version
load Gem.bin_path('railties', 'rails', version)
I tried removing and reinstalling RVM but i did not work.
Also i tried making app with ruby 2.1.5 with different gemset and all, but there i get different error when i try to do rails new app. i get the Could not find slop-3.6.0 in any of the sources
Run 'bundle install' to install missing gems., but once i do the bundle install i cannot run the rails new app command as it notifies
Can't initialize a new Rails application within the directory
of another, please change to a non-Rails directory first.
Any help would be greatly appreciated. If you need any more info i am ready to provide it.
Thanks in advance.
Cheers.
I had similar issues and restarting from scratch using this guide helped a lot. Though it seemed yet another guide, I found it to be a bit more systematic and detailed than the others.
Rails Apps Guide: Install Ruby on Rails · Ubuntu Linux
Alternatively, try Rails Apps Guide: Updating to Rails 4.2
Note:
Rails is not just a Ruby gem, it is a complex and rapidly evolving
ecosystem. It is important to set up your development environment with
the most current version of all the gems that are needed for
development.
I'm trying to install Rails 3.2.8 to a linux box without internet connection. I've manually downloaded all the related gem packages and copied them to the linux box. When I try to install some of those packages, I got error. e.g., :
[jw#web gems]$ sudo /usr/local/bin/gem install --local ./activemodel-3.2.8.gem
ERROR: While executing gem ... (Gem::DependencyError)
Unable to resolve dependencies: activemodel requires builder (~> 3.0.0)
The strange thing is that some packages can be installed this way. e.g., the builder has already been installed. Please note that all the dependencies required are there.
How come the dependencies is unable to resolve ?
My environment:
Ruby: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
Rubygem: 1.8.23
My installed gems:
[jw07#web gems]$ gem list
*** LOCAL GEMS ***
activesupport (3.2.8)
arel (3.0.2)
bigdecimal (1.1.0)
builder (3.1.3)
bundler (1.2.0)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.1)
io-console (0.3)
journey (1.0.4)
json (1.7.5)
mail (2.4.4)
mime-types (1.19)
minitest (2.5.1)
multi_json (1.3.6)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rake (0.9.2.2)
rdoc (3.9.4)
sprockets (2.5.0)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)
It does not look like Rubygems version is a problem.
You see rails requires gem builder ~> 3.0.0, but you have 3.1.3 which does not match (~> means it will match 3.0.x, but not 3.1.x). You have to install builder 3.0.3.
Another possibility could be there is another gem in your Gemfile that requires builder 3.1.x, causing a conflict. It would be helpful if you provided your Gemfile.
Try to upgrade to the latest RubyGems:
gem update --system
And install rails with dependencies:
gem install rails --include-dependencies
I'm trying to run "bundle install" and it seems to have an issue with finding the appropriate gemfile even though I installed the gem bundler. I'm not sure what to do from here. When I run "bundle install" I get this:
C:\Users\User1\Sites\simple_cms>bundle install
Fetching gem metadata from http://rubygems.org/.........
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 3.0.0) x86-mingw32 depends on
bundler (~> 1.0.0) x86-mingw32
Current Bundler version:
bundler (1.1.3)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
So then I install the bundler gem which appears to install just fine.
C:\Users\User1\Sites\simple_cms>gem install bundler
Successfully installed bundler-1.1.3
1 gem installed
Installing ri documentation for bundler-1.1.3...
Installing RDoc documentation for bundler-1.1.3...
But even though the install for the bundler gem succeeded "bundle install" still fails:
C:\Users\User1\Sites\simple_cms>bundle install
Fetching gem metadata from http://rubygems.org/.........
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 3.0.0) x86-mingw32 depends on
bundler (~> 1.0.0) x86-mingw32
Current Bundler version:
bundler (1.1.3)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
When I run "gem list" the bundler is definitely there:
C:\Users\User1\Sites\simple_cms>gem list
*** LOCAL GEMS ***
actionmailer (3.2.3)
actionpack (3.2.3)
activemodel (3.2.3)
activerecord (3.2.3)
activeresource (3.2.3)
activesupport (3.2.3)
arel (3.0.2)
bigdecimal (1.1.0)
builder (3.0.0)
bundler (1.1.3)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.3.1)
erubis (2.7.0)
execjs (1.3.1)
hike (1.2.1)
i18n (0.6.0)
io-console (0.3)
journey (1.0.3)
jquery-rails (2.0.2)
json (1.7.0, 1.5.4)
mail (2.4.4)
mime-types (1.18)
minitest (2.5.1)
multi_json (1.3.4)
mysql2 (0.3.11 x86-mingw32)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.3)
railties (3.2.3)
rake (0.9.2.2)
rdoc (3.12, 3.9.4)
rubygems-update (1.8.24)
sass (3.1.16)
sass-rails (3.2.5)
sprockets (2.1.3)
sqlite3 (1.3.6 x86-mingw32)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)
uglifier (1.2.4)
C:\Users\User1\Sites\simple_cms>
Try to remove your Gemfile.lock. Then run bundle check and see the output. It may ask you to run bundle install again.
It looks to me like your version of Rails (3.0.0) requires Bundler 1.0.0 -- you have a newer version.
You can install a specific version through gem install like this:
gem install bundler -v 1.0.0
I suggest you don't copy and paste whole projects.
First of all learn to use rvm or rbenv so you don't encounter conflicts with ruby versions and gems.
if your tutorial uses rails 3.0, you can put in something like
gem 'rails', '3.0.0'
in your Gemfile.
I suggest you install the latest rails version though and learn that.
I want to setup different rails versions with RVM. However, working with the SQLite gives problem.
First, doing
gem list -ra sqlite
gives
*** REMOTE GEMS ***
sqlite-foreigner (0.5.0)
sqlite-ruby (2.2.3 ruby mswin32, 2.2.2 ruby mswin32, 2.2.1 ruby mswin32, 2.2.0 ruby mswin32, 2.1.0 ruby mswin32, 2.0.3)
sqlite3 (0.1.1, 0.1.0, 0.0.8, 0.0.7, 0.0.6, 0.0.5, 0.0.4, 0.0.3, 0.0.2, 0.0.1, 0.0.0)
sqlite3-dotnet (3.7.2.1, 3.7.2.0)
sqlite3-ironruby (0.1.1, 0.1.0)
sqlite3-ruby (1.3.1 ruby x86-mingw32 x86-mswin32-60, 1.3.0 ruby x86-mingw32 x86-mswin32-60, 1.2.5 ruby x86-mingw32 x86-mswin32, 1.2.4, 1.2.3 ruby mswin32 x86-mingw32, 1.2.2 ruby mswin32, 1.2.1 ruby mswin32, 1.2.0 ruby mswin32, 1.1.0 ruby mswin32, 1.0.1 ruby mswin32, 1.0.0 ruby mswin32, 0.9.0 ruby mswin32, 0.6.0, 0.5.0)
sqlitecache (0.0.1)
I am working with MacOS X 10.6, Sqlite3 3.7.2
Can I work with multiple versions of Sqlite3?
What gems would I need in my RVM environment?
Currently:
*** LOCAL GEMS ***
actionmailer (2.2.3, 2.2.2)
actionpack (2.2.3, 2.2.2)
activerecord (2.2.3, 2.2.2)
activeresource (2.2.3, 2.2.2)
activesupport (2.2.3, 2.2.2)
ffi (0.6.3)
haml (2.2.0)
rails (2.2.3, 2.2.2)
rake (0.8.7)
ruby-openid (2.0.4)
And RVM list:
rvm rubies
ree-1.8.6-20090610 [ x86_64 ]
=> ruby-1.8.6-p399 [ x86_64 ]
ruby-1.9.2-p0 [ x86_64 ]
you can install multiple sqlite3 packages simultaneously with gem. and you can select the specific gem version with the following lines:
require 'rubygems'
gem 'sqlite3', '=0.1.0'
require 'sqlite3'
To install it type:
gem install sqlite3 -v '0.1.0'
I think you can use any sqlite3 gem with any RVM, but you can check their webpage