Rails console doesn't work (openshift) - ruby-on-rails

I have been using openshift for a week now, and everything works fine. Unfortunately, neither with Ruby2.0 or Ruby1.9.3 can I access the Rails4 console online, which is a real problem.
bundle exec rails console RAILS_ENV="production"
fails, asking me to run bundle install, and bundle install fails, telling me it can't install active support 4.1.4, even though during deployment openshift says it is installed in .vendor/bundle. I tried deleted my app several times, recreating, starting with a clean version of the railsapp example on github... nothing works.
I hope you can help me, thanks in advance
[app-root/repo]$ bundle exec rails console RAILS_ENV="production"
bundler: command not found: rails
Install missing gem executables with `bundle install`
[app-root/repo]$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Using rake (0.9.6)
Using i18n (0.6.11)
Using json (1.8.1)
Using minitest (5.4.0)
Using thread_safe (0.3.4)
Using tzinfo (1.2.1)
Installing activesupport (4.1.4)
Gem::InstallError: activesupport requires Ruby version >= 1.9.3.
An error occurred while installing activesupport (4.1.4), and Bundler
cannot continue.
Make sure that `gem install activesupport -v '4.1.4'` succeeds before
bundling.
[app-root/repo]$ gem install activesupport -v '4.1.4'
Fetching: i18n-0.6.11.gem (100%)
Successfully installed i18n-0.6.11
Fetching: thread_safe-0.3.4.gem (100%)
Successfully installed thread_safe-0.3.4
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: activesupport-4.1.4.gem (100%)
Successfully installed activesupport-4.1.4
4 gems installed
[app-root/repo]$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Using rake (0.9.6)
Using i18n (0.6.11)
Using json (1.8.1)
Using minitest (5.4.0)
Using thread_safe (0.3.4)
Using tzinfo (1.2.1)
Installing activesupport (4.1.4)
Gem::InstallError: activesupport requires Ruby version >= 1.9.3.
An error occurred while installing activesupport (4.1.4), and Bundler
cannot continue.
Make sure that `gem install activesupport -v '4.1.4'` succeeds before
bundling.
I am using the Gemfile provided on Github, with minor changes. I had to modify the following lines a bit, or rails would complain:
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
had to be replaced by
group :development do
gem 'spring'
end
group :doc do
gem 'sdoc', '~> 0.4.0'
end
Just ask if you need more info.

I use
cd ~/app-root/repo && RAILS_ENV=production bundle exec rails console
And it works fine for me.

OpenShift is quite picky with the Gemfile format:
In my case it was:
gem 'guard-rspec', require: false
Has to be:
gem 'guard-rspec', :require => false
That fixed the first error, bundle was complaining about the file format, and then I had the problem of the gems not being there.
So again I connected to the console and did a gem install bundler in
app-deployment/current/repo
and
~/.gem/bin/bundle exec rails c
did work this time

Related

install ruby on rails Mac os

hello guys i have checked all people sharing about installing ruby on rails but its the same problem
like this:
Fetching selenium-webdriver 3.4.3
Using listen 3.1.5
Using rails-dom-testing 2.0.3
Using globalid 0.4.0
Using activemodel 5.1.2
Using jbuilder 2.7.0
Using spring 2.0.2
Using rails-html-sanitizer 1.0.3
Using capybara 2.14.4
Bundler::GemspecError: Could not read gem at
/usr/local/lib/ruby/gems/2.4.0/cache/selenium-webdriver-
3.4.3.gem. It may be
corrupted.
An error occurred while installing selenium-webdriver (3.4.3), and
Bundler cannot continue.
Make sure that gem install selenium-webdriver -v '3.4.3' succeeds before
bundling.
In Gemfile:
selenium-webdriver
run bundle exec spring binstub --all
Could not find gem 'sass-rails (~> 5.0)' in any of the gem sources listed in your Gemfile.
Run bundle install to install missing gems.
I have experience with this driver, and downgraded to lower version here is the sample that work with my system, you can delete minitest incase you don't need it. I'm using rails 5.0.2
group :development, :test do
gem 'selenium-webdriver', '2.53.4'
gem 'minitest-rails-capybara'
gem 'minitest-reporters'
end
Bundler is trying to fetch the selenium-webdriverfrom its cache. Also, bundler suggests that the package is probably corrupt. You can try removing it from cache so bundler can install the gem again.
rm -f /usr/local/lib/ruby/gems/2.4.0/cache/selenium-webdriver-3.4.3.gem
bundle install

Could not find 'ruby-debug-ide' in VS Code

I am trying to use VS Code for debugging a Ruby on Rails application. I have installed both the Ruby and Rubocop extension into VS Code. Then I have installed ruby-debug-ide -v 0.6.0 and debase -v 0.2.1 both via sudo gem install and rvmsudo gem install. However, when trying to debug the application using Rails server, I get the following exception:
/usr/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs'
:
Could not find 'ruby-debug-ide' (>= 0.a) among 48 total gem(s)
(
Gem::LoadError
)
Checked in 'GEM_PATH=/home/myname/.rvm/gems/ruby-2.3.1:/home/myname/.rvm/gems/ruby-2.3.1#global', execute `gem env` for more information
from /usr/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
from /usr/local/bin/rdebug-ide:22:in `<main>'
However, when I list all installed gems with rvm all do gem list, neither of the installed gems are there:
*** LOCAL GEMS ***
...
concurrent-ruby (1.0.2)
did_you_mean (1.0.0)
erubis (2.7.0)
...
rdoc (4.2.1)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
...
Does anybody know how to fix this?
In my case, the solution was quite simple. As a newbie in Ruby on Rails, I did not realize that instead of installing gems into Ruby root, I should specify them in my Gemfile. So, inside Gemfile I put only:
group :development do
gem 'ruby-debug-ide', '0.6.0'
gem 'debase', '0.2.1'
gem 'web-console', '~> 2.0'
gem 'spring'
end
and this solved the issue for me.
I also had this issue for a while, there doesn't seem to be a clear cut way of resolving this problem. All I had to do was run vs code through the terminal and I could debug my rails project, assuming you are using Linux. Just make sure you don't open vs code via a shortcut.

Could Not Find Gem, but Gem is Installed without Problems

Whenever I run the rails server or the specs, I get this error:
Could not find debugger-1.6.8 in any of the sources
When I run gem install debugger, it works just fine:
Building native extensions. This could take a while...
Successfully installed debugger-1.6.8
1 gem installed
Installing ri documentation for debugger-1.6.8...
Installing RDoc documentation for debugger-1.6.8...
(eval):5: warning: regular expression has ']' without escape: /\[a-z]+/
but the bundler list doesn't show debugger-1.6.8:
* daemons (1.2.3)
* delayed_job (4.0.3)
* delayed_job_active_record (4.1.0)
* diff-lcs (1.2.5)
* domain_name (0.5.25)
* double-bag-ftps (0.1.2)
I also don't have a .bundle/config file that is preventing any gems from being installed.
Here is my Gemfile with the :test and :development group:
group :test, :development do
gem 'sqlite3', '1.3.9'
gem 'rspec-rails', '~> 2.14.2'
gem 'pry'
gem 'awesome_print', '1.2.0'
gem 'debugger', platform: :mri_19
gem 'byebug' if RUBY_VERSION >= '2.0.0'
end
When i remove the platform specification, i get this error:
An error occurred while installing debugger (1.6.8), and Bundler cannot continue.
Make sure that `gem install debugger -v '1.6.8'` succeeds before bundling.
I am running ruby 1.9.3-p551 with rbenv.
How do I get the debugger gem installed into the project bundle so I can run my server and tests?
Re-install your bundler gem and rbenv (via brew). Sometimes these installations can go bad, and the permissions on your machine will be sad when bundler and rbenv go to set your gems.

jruby -S bundle does not run as it says jruby-openssl gem missing

I'm using Jruby 1.6.7 with ruby >1.9. when I run `jruby -S bundle, I see the following error
Fetching gem metadata from https://rubygems.org/.JRuby limited openssl loaded. http://jruby.org/openssl
gem install jruby-openssl for full support.
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at .... Thanks!
LoadError: OpenSSL::SSL requires the jruby-openssl gem
My Gemfile has this open-ssl already
source 'https://rubygems.org'
gem 'rails', '3.2.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'activerecord-jdbcsqlite3-adapter'
gem 'activerecord-oracle_enhanced-adapter', '~>1.4.1'
gem 'jruby-openssl'
and here is part of my Gemfile.lock
jdbc-sqlite3 (3.7.2)
journey (1.0.4)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
jruby-jars (1.6.7.2)
jruby-openssl (0.7.7)
bouncy-castle-java (>= 1.5.0146.1)
jruby-pageant (1.1.1-java)
jruby-rack (1.1.7)
json (1.7.3-java)
Why am I still getting this error saying that open-ssl is missing?
This question is totally related to this one and my problem will be solved if I am able to execute jurby -S bundle here.
Update:
The error started after I ran bundle install --deployment.
So I ran bundle install --no-deployment then bundle install, jurby -S bundle..everything works fine. I'm not able to understand what is happening here.
Execute jruby -S gem install jruby-openssl before you run your bundle command.

Application Error on heroku

I'm follow an online railstutorial.
I'm a newbie, and now I finished just my second app.
It works ok on a local machine, but I have a problem with heroku.
I pushing my app successfully, and then I done heroku rake db:migrate
But I see this error on my page
An error occurred in the application and your page could not be
served. Please try again in a few moments. If you are the application
owner, check your logs for details
And I see this warning in command line:
rake aborted! Please install the postgresql adapter: gem install
activerecord-postgresql-adap ter (pg is not part of the bundle. Add
it to Gemfile.)
I google this error and found that I need add this strings to my gemfile:
gem 'sqlite3', :group => :development
gem 'pg', :group => :production
Done it, and retried, but nothing changed, and I still have this in my command line
Please install the postgresql adapter: gem install
activerecord-postgresql-adap ter (pg is not part of the bundle. Add
it to Gemfile.)
I can't understand it, cause I defenitely had pg gem, and I can see his installation on my local machine
Using thor (0.14.6)
Using railties (3.2.1)
Using coffee-rails (3.2.2)
Using jquery-rails (2.0.2)
Using pg (0.13.2)
Using rails (3.2.1)
Using sass (3.1.16)
Using sass-rails (3.2.5)
Using sqlite3 (1.3.6)
Using uglifier (1.2.4)
but I can't see the same, when bundle installing on heroku server
Installing thor (0.14.6)
Installing railties (3.2.1)
Installing coffee-rails (3.2.2)
Installing jquery-rails (2.0.2)
Using bundler (1.0.7)
Installing rails (3.2.1)
Installing sass (3.1.16)
Installing sass-rails (3.2.5)
Installing uglifier (1.2.4)
How can I solve it? Really have no idea. Please help me.
btw, sorry for my english, I'm from russia)
update:
yeah, i see that it runs bundle install --without development, but my gemfile now looks like:
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3-ruby', :require => 'sqlite3'
end
as you can see, 'pg' is definitely out of development group, but heroku didn't install it
Looks like you added the pg gem to the development group in your Gemfile - when Heroku deploys, it runs bundle install --without development, meaning that it'll not install gems in that group. Move the gem outside of the development group.
If you've updated your Gemfile make sure you commit it and the Gemfile.lock to git and then repush your application to Heroku.

Resources