I lose my patience to rails on ubuntu. So far I have used the ready environment on c9, but it is slowly closing. I'm learning how to deal with rails and I have a problem with Ubuntu.
I use tutorials (many) to install it. Finally, I did it, and I created a small project. One page + one model + one controller. Commit, exit, turn off a notebook.
Today when I want to back to programming I opened a terminal and go to project dir /Desktop/Projc/test. And after typed rails s I got the message:
Command 'rails' not found, but can be installed with:
sudo apt install ruby-railties
And what is weird, If I open a terminal in home dir rails are ok. I can create a new project etc. But in the existing project rails "are not installed".
I spent a few hours to look for a solution, reads many posts (so: 10918685, 7788946, 16884034) but nothing help.
I'm afraid that I just did a bigger mess.
Can someone try to help me with my case?
My configs:
gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.1
- RUBY VERSION: 2.6.1 (2019-01-30 patchlevel 33) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/iso/.rvm/gems/ruby-2.6.1
- USER INSTALLATION DIRECTORY: /home/iso/.gem/ruby/2.6.0
- RUBY EXECUTABLE: /home/iso/.rvm/rubies/ruby-2.6.1/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /home/iso/.rvm/gems/ruby-2.6.1/bin
- SPEC CACHE DIRECTORY: /home/iso/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /home/iso/.rvm/rubies/ruby-2.6.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/iso/.rvm/gems/ruby-2.6.1
- /home/iso/.rvm/rubies/ruby-2.6.1/lib/ruby/gems/2.6.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/iso/.rvm/gems/ruby-2.6.1/bin
- /home/iso/.rvm/gems/ruby-2.6.1#global/bin
- /home/iso/.rvm/rubies/ruby-2.6.1/bin
- /home/iso/.rvm/bin
- /home/iso/.rbenv/plugins/ruby-build/bin
- /home/iso/.rbenv/shims
- /home/iso/.rbenv/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /snap/bin
echo $PATH:
/home/iso/.rvm/gems/ruby-2.6.1/bin:/home/iso/.rvm/gems/ruby-2.6.1#global/bin:/home/iso/.rvm/rubies/ruby-2.6.1/bin:/home/iso/.rvm/bin:/home/iso/.rbenv/plugins/ruby-build/bin:/home/iso/.rbenv/shims:/home/iso/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
rails -v: 5.2.3
ruby -v: 2.6.0p0
Can someone see a solution? And in the terminal, I have a checked a "run as start shell".
Related
I have Jenkins automation server that connects to my machine through ssh with user snaggs.
My machine has 2 versions of ruby:
default version comes from OS /System/Library/Frameworks/ ..... /usr/bin/ruby
ruby v2.3.3 installed with RVM
On machine the automation runs some Perl script with some commands. whoami from jenkins gives snaggs
When Perl script runs command gem env the output is:
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.14.1
- RUBY VERSION: 2.0.0 (2015-12-16 patchlevel 648) [universal.x86_64-darwin16]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-16
- GEM PATHS:
- /Library/Ruby/Gems/2.0.0
- /Users/snaggs/.gem/ruby/2.0.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://rubygems.org"]
- REMOTE SOURCES:
- http://rubygems.org
However when I enter to the same machine with ssh to the same user snaggs I have ruby version installed with rvm:
When I run $ gem env I get output:
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.8
- RUBY VERSION: 2.3.3 (2016-11-21 patchlevel 222) [x86_64-darwin16]
- INSTALLATION DIRECTORY: /Users/snaggs/.rvm/gems/ruby-2.3.3
- USER INSTALLATION DIRECTORY: /Users/snaggs/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /Users/snaggs/.rvm/rubies/ruby-2.3.3/bin/ruby
- EXECUTABLE DIRECTORY: /Users/snaggs/.rvm/gems/ruby-2.3.3/bin
- SPEC CACHE DIRECTORY: /Users/snaggs/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/snaggs/.rvm/rubies/ruby-2.3.3/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-16
- GEM PATHS:
- /Users/snaggs/.rvm/gems/ruby-2.3.3
- /Users/snaggs/.rvm/gems/ruby-2.3.3#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://rubygems.org"]
- REMOTE SOURCES:
- http://rubygems.org
- SHELL PATH:
- /Users/snaggs/.rvm/gems/ruby-2.3.3/bin
- /Users/snaggs/.rvm/gems/ruby-2.3.3#global/bin
- /Users/snaggs/.rvm/rubies/ruby-2.3.3/bin
- /usr/local/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/snaggs/.rvm/bin
How to tell to Jenkins to use other version located under /Users/snaggs/.rvm/gems/ruby-2.3.3?
[EDIT]
I don't run script as super user
I had a similar problem when tried to configure Java version.
Take a look at Jenkins wiki:
When the SSH slaves plugin connects to a slave, it does not run an
interactive shell. Instead, it does the equivalent of your running "ssh
slavehost command..."
So suppose when you will run gem env from ssh, you should get the same result like Jenkins gets: ssh snaggs#1.1.1.1 "gem env"
On machine the automation runs some Perl script with some commands.
You can try to create some custom .bash_profile_CUSTOM that equals to your original .bash_profile You need to call .bash_profile_CUSTOM because Jenkins uses own .bash_profile by default .Run your perl script like:
ssh snaggs#1.1.1.1 "source ~/.bash_profile_CUSTOM && perl some_perl_script.pl"
Just remember that you need to bind bash_profile_CUSTOM file each time Jenkins connects to your build machine. So from Jenkins the command executable should be something like:
source ~/.bash_profile_CUSTOM && perl some_perl_script.pl
let me know if it works or give you different output
Edit: (25/12/2016)
If you don't want to install plugins for Jenkins (like EnvInject Plugin for Prefix Start Slave Command) you can wrap Perl script with bash script, like:
#!/bin/bash
source ~/. bash_profile_CUSTOM;
perl some_perl_script.pl;
So Perl script will start with profile you defined with .bash_profile_CUSTOM.
I've installed ruby, rubygems and rails through Cygwin setup.
Then I've installed a gem:
gem install capistrano --verbose
No problem here. But when I try to run cap command, Cygwin tells me:cap: command not found
When I execute in ./bin/cap it works:
$ ./bin/cap
Stage not set, please call something such as 'cap production deploy', where production is a stage you have defined.
Here is my gem environment:
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.1
- RUBY VERSION: 2.0.0 (2014-11-13 patchlevel 598) [i386-cygwin]
- INSTALLATION DIRECTORY: /home/Moretti/.gem/ruby
- RUBY EXECUTABLE: /usr/bin/ruby.exe
- EXECUTABLE DIRECTORY: /home/Moretti/bin
- SPEC CACHE DIRECTORY: /home/Moretti/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /etc
- RUBYGEMS PLATFORMS:
- ruby
- x86-cygwin
- GEM PATHS:
- /home/Moretti/.gem/ruby
- /usr/share/gems
- /usr/local/share/gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/bin
- /usr/bin
- /cygdrive/c/Program Files (x86)/Intel/iCLS Client
- /cygdrive/c/Program Files/Intel/iCLS Client
- /cygdrive/c/WINDOWS/system32
- /cygdrive/c/WINDOWS
- /cygdrive/c/WINDOWS/System32/Wbem
- /cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0
- /cygdrive/c/Program Files/Intel/Intel(R) Management Engine Components/DAL
- /cygdrive/c/Program Files/Intel/Intel(R) Management Engine Components/IPT
- /cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Componen ts/DAL
- /cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Componen ts/IPT
- /usr/bin
The EXECUTABLE DIRECTORY is correct, but the binaries aren't working outside the ~/bin/.
What can I do?
I created a cap file in /usr/local/bin/ and made it executable.
$ cat /usr/local/bin/cap
#!/bin/bash
ruby ~/.gem/ruby/gems/capistrano-3.3.5/bin/cap "$#"
Location of capistrano gem files can be found using gem which capistrano.
I personally do not know if this is the best way of doing it, but I've just set it up yesterday and have managed to get it working for my usecase
I'm trying to run a single unit test in my Rails app, I'm using the following command to run the test (say my model is users)
rake test TEST=test/unit/user_test.rb
It runs with out a problem, but for some reason it runs three times; can anyone explain me why is that and if I'm doing something wrong above? Following is my gem env, and I'm using Rails 2.3.2.
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.10
- RUBY VERSION: 1.8.7 (2011-12-28 patchlevel 357) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/sameera/.rvm/gems/ruby-1.8.7-p357
- RUBY EXECUTABLE: /home/sameera/.rvm/rubies/ruby-1.8.7-p357/bin/ruby
- EXECUTABLE DIRECTORY: /home/sameera/.rvm/gems/ruby-1.8.7-p357/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/sameera/.rvm/gems/ruby-1.8.7-p357
- /home/sameera/.rvm/gems/ruby-1.8.7-p357#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
In a rails app rake test runs 3 subtasks, test:units, test:functionals, test:integration.
Each of those tasks just runs all the tests from the corresponding folder, but your environment variable overrides that search process and so the same file is found each time.
You could either do
rake test:units TEST=...
or
ruby -I test test/unit/user_test.rb
Using heroku for deployment while learning Rails with the Ruby On Rails tutorial by Michael Hartl, on Ubuntu 11.04 Natty Narwhal. I installed it using
sudo gem install heroku
and the commands seemed to run fine for that session in the terminal. The next time I went to work, I tried the command "heroku open" and I was told "heroku: command not found". Looking at some of the answers to similar problems here, it seemed the answer was to run
gem enviroment
which returned the following:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /var/lib/gems/1.8
- /home/richard/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I then ran
$ export PATH=$PATH:/var/lib/gems/1.8/bin
which seemed to fix the problem. However, the next time I tried to run heroku in the terminal, I was told "command not found" again! Running the "export PATH=$PATH" command seems to fix the problem every time, but I would rather I didn't have to run this command everytime I want to use heroku. Is there any permanent solution to the problem?
If you're using bash as your shell, then add that export line to .bash_profile in your home directory. The equivalent for zsh is .zshrc, and other shells have their own files to automatically load for every shell session.
I'm currently trying to get Thin webserver running on Windows, to form a basic cluster behind a NGINX proxy, but this is proving to be rather difficult.
I was wondering if anyone actually succeeded in getting this up and running?
To give some examples of the things I have tried:
C:\Users\arne.de.herdt.TENFORCE2\RubymineProjects\ESCO>thin start
C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems.rb:926:in `report_activate_error': Rub
yGem version error: thin(1.2.11 not >= 0) (Gem::LoadError)
from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems.rb:244:in `activate_dep'
from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems.rb:236:in `activate'
from C:/Ruby/lib/ruby/site_ruby/1.9.1/rubygems.rb:1307:in `gem'
from C:/Ruby/bin/thin:18:in `<main>'
I really don't get this error message. I've included below the environmental output of my system that I'm trying this on (my development system)
RubyGems Environment:
- RUBYGEMS VERSION: 1.7.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [i386-mingw32]
- INSTALLATION DIRECTORY: C:/Ruby/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: C:/Ruby/bin/ruby.exe
- EXECUTABLE DIRECTORY: C:/Ruby/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mingw32
- GEM PATHS:
- C:/Ruby/lib/ruby/gems/1.9.1
- C:/Users/arne.de.herdt.TENFORCE2/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Hoping someone has been experimenting with this.
Also I must say that it's starting to annoy me that the lack for Windows support is such a serious issue with Ruby on Rails. I really enjoy the language and programming in it, but it's a pain getting things to work on Windows machines because of uncompilable dependencies...
Thin ain't supported under Windows.....