Getting cross-thread violation when installing rails - ruby-on-rails

I am running ruby 1.9.2 p180 using rvm.
I tried to install rails:
sudo gem install rails
And I got this:
Successfully installed activerecord-3.1.3
Successfully installed activeresource-3.1.3
Successfully installed mail-2.3.0
Successfully installed actionmailer-3.1.3
Successfully installed rack-ssl-1.3.2
Successfully installed rdoc-3.12
Successfully installed railties-3.1.3
Successfully installed rails-3.1.3
22 gems installed
[BUG] cross-thread violation on rb_gc()
(null)
I was using 1.8.7 all this time, but wanted to try using 1.9.2 as that is where things seem to be moving and ran into this bug.
What could it be?

See the section "Bus Error / Segfault" in Troubleshooting RVM:
In every case of this I have seen thus far it has always ended up being that a ruby gem/library with C extensions was compiled against a different ruby and/or architecture than the one that is trying to load it. Try uninstalling & reinstalling gems with C extensions that your application uses to hunt this buggar down.
No guarantees that this is the problem, but ensure that all of your gems were compiled for the architecture you are running on (64-bit vs. 32-bit, for example). You didn't mention the platform/architecture in your post. If you are running OSX, see OSX, RubyGems and cross-thread violations in rb_gc, as well. Chances are you are picking up some of the 1.8.7 gems.

Why did you run sudo gem with RVM?
Have you tried:
rvm use rails-1.9.2-p180
gem install rails
under the folder you are creating the app you can also create a .rvmrc file with the ruby version you are running so everytime you ge into the folder you it would switch to the version set in the .rvmrc
sample:
rvm ruby-1.9.2-p180#myapp

Related

Rails bundler is not finding correct Ruby version in OSX Catalina

I've recently upgraded to OSX Catalina and when I try to do
bundle install
on the Rails project, I get an error:
Cannot bundle the project, current system is on Ruby 2.6.3 and gemfile
specified Ruby 2.4.2.
What's bizarre is that the Catalina system is a fresh install and I used rbenv to do a single install of Ruby version 2.4.2. In fact, if I run
ruby -v
It comes back with ruby version 2.4.2 as the only ruby version installed (and the default).
I'm totally stumped, has anyone else seen this behaviour or have any idea of how I can resolve this?
So I finally solved this, although I'm a little mystified as to the cause/solution.
Basically, I uninstalled the bundler gem and installed the one the project had in it's Gemfile (1.16.2)
For whatever reason, I'm not sure how bundler got installed on the fresh machine, I suspect maybe through RVM or Rbenv, but with that version of bundler it was somehow assuming that I had Ruby 2.6.3 installed, even though it didn't appear as a version on my machine.

What's the best way to run a RoR project on my localhost

I have a friend's website code, which is in Ruby on Rails.
I have tried to install RoR on my Mac using instructions at gorails.com
OS : Mac Mojave
ruby -v : ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin18]
rails -v :
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems.rb:241:in `bin_path': can't find gem railties (>= 0.a) (Gem::GemNotFoundException)
from /usr/local/bin/rails:22:in `<main>'
What I tried : I installed ruby, and then rails, using gorails tutorial, and kept getting errors stating version number mismatch.
Keep in mind that creating a new app, worked, but trying to run this existing code is a problem.
So then I uninstalled everything and updated the version using rvm, and since then I am getting this error.
When I cd into the webapp folder and run bundle install, I get errors, such as:
zsh: /Users/abc/.rvm/gems/ruby-2.2.3#hs/bin/bundle: bad interpreter: /Users/abc/.rbenv/versions/2.5.3/bin/ruby: no such file or directory
Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your
Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using
RVM are available at rvm.io/packages/openssl.
This project uses a PostgreSQL database, which I have setup already.
If required, I can share the gemfile of this project too.
What is the best way to get this project working?
Am I missing something crucial?
You can't run RVM and RBENV on the same machine. Pick one and remove the other. You're probably best to uninstall both and then pick one, start over.
Uninstall RBENV instructions here or in your case probably brew uninstall rbenv
Uninstall RVM see How can I remove RVM (Ruby Version Manager) from my system?
Close all terminals and then start a new one.
Install RVM see https://rvm.io/rvm/install
Then go to your project, make sure you have the correct ruby version needed by your project. If not, you will need to install with rvm install 2.5.1 for example.
Then run
rvm use 2.5.1 #or some other version
Then you should be able to run bundle install
The rest of the instructions in your link should be ok.

Why does a Ruby version update require installing bundler?

My application was running fine with Ruby 2.2.4, until running a test gave me an error saying "the ruby version you're using is outdated/buggy".
So I updated and used Ruby 2.3.0 as the default for my application. After that I got an error saying "could not find bundler".
I already had bundler, so why does updating the Ruby version require reinstalling bundler into my application?
(I am learning Ruby-on-Rails, so treat me as a beginner.)
Each copy of Ruby installed on a computer has its own set of installed gems. One reason that gems aren't shared between installations of Ruby is that some gems include compiled native code, and the compiled output might be different for different versions of Ruby.
bundler is a standalone gem, not part of Ruby, so whenever you install a new Ruby you have to install bundler in that Ruby.
This is independent of whether you're using a Ruby version manager (chruby, rbenv, rvm, etc.); if you install a new Ruby, it needs its own set of installed gems.
Whenever you install a new version of Ruby with RVM it creates a wrapper with what they call gemsets. Gemsets are not shared between ruby version so therefore when you installed your new Ruby 2.3.0 it installed without any gems.
To fix this problem simply install bundler by running gem install bundler.
Once that's done, you should have it available for your new installation of Ruby.
I also had faced such issue. First I run this with selected RVM version.
gem install bundle
Then you should run:
bundle install
In your project directory.
Please let me know if you have any confusion.

Rails doesn't complete installation on OS X Lion

I'm quite new to Ruby in general and especially RoR, so tell me if I need to add more information.
Upon running sudo gem install rails (after a long delay) I receive the following error message:
ERROR: While executing gem ... (Gem::RemoteFetcher::UnknownHostError)
no such name (https://api.rubygems.org/quick/Marshal.4.8/mime-types-1.17.2.gemspec.rz)
I entered the link and it downloaded something, so I tried again - not entirely surprisingly, I got the same error.
I'm running OSX 10.7.5 and I've installed XCode 4.6.3 as well as the command line tools. I've installed Ruby 2.1.0 so I know I have that up to date. I thought the error might have something to do with sudo typically running whatever came with the machine, but if that's true, wouldn't it give me an error saying I needed a version of Ruby >= 1.9.3?
To be perfectly clear what I'm asking: why will Rails not install under the above conditions, and how can this be remedied?
Edit: I ran the command yet another time and this time it worked, and I don't know why it didn't before or what made it work now. As a note for anyone who should care, I do have RVM installed and used it to install Ruby.
OS X comes with ruby 1.8.x
My guess is that you are still defaulting to that version and not the 2.1 you have installed.
I would recommend installing RVM or equivalent so that you can shift from system 1.8.x to your 2.1 (or else as you can manage several versions of ruby and rails with RVM)
I would recommend against installing rails as root. I ran into this issue where
ruby -v
returned ruby 2.1.0 and
sudo ruby -v
returned ruby 1.9.1
Every time I tried to run
gem install rails
I kept getting errors as a result. I'm not familiar with Mac's package manager but this is what worked for me on ubuntu
sudo apt-get remove ruby1.9.1
then
sudo ruby -v
should return command not found. Then installing rails worked fine
gem install rails
These were the directions I followed. The main problem was I had already installed ruby prior to running(I think heroku toolbelt did it).
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm

"msvcrt-ruby18.dll was not found" with Ruby

When I try to run even simple rails commands such as:
rails -h
I get a popup error after a few seconds that says:
ruby.exe - Unable To Locate Component
This application has failed to start
because msvcrt-ruby18.dll was not
found. Re-installing the application
may fix the problem.
I am running:
Windows XP (yes I know I should attempt ruby on a Windows machine).
Ruby 1.9.1p378 [i386-mingw32].
Have updated all my gems to latest versions (as of 14-July-2010).
Is there a way I can test what is making this error? Does anyone know what it could mean?
I have found that in my ruby19/bin folder there is msvcrt-ruby191.dll but there is no msvcrt-ruby18.dll anywhere. Why would it be looking for this anyway if I'm using ruby 1.9?
The current release version 1.1.5 of Mongrel is incompatible with Ruby 1.9 and throws this error when it is run. It's easy to solve - just make sure Rubygems is up-to-date:
gem update --system
Then install the new pre-release version of Mongrel:
gem install mongrel --pre
Alternatively, if this isn't caused by Mongrel, you can try installing the DevKit, then try this:
gem install *gemname* --platform=ruby
This forces compilation of the extension from source using DevKit and works with most of the major gems I've tried.
Ruby 1.9.1 was running well on my Windows XP PC, but I've got this error message after installing mongrel. Unfortunately, mongrel has no update for Ruby 1.9.1 yet. Perhaps, for this reason, it generates this error on my PC.
JRuby might work better for you. Either way, trying to use Ruby on Windows will leave a bad taste in your mouth. Either get a VM with Linux to work with it, or pay $10/mo for a VPS where you can play.
you got the binary version of the gem, which only includes binaries for 1.8
try gem install mongrel --platform=ruby --pre
To solved msvcrt-ruby.dll error
Install DevKit ( https://github.com/oneclick/rubyinstaller/wiki/Development-Kit )
> gem uninstall json
> gem install json

Resources