Ruby on windows causes error Cannot load such file bcrypt_ext - ruby-on-rails

Trying to run ruby on my Windows 7 machine whenever i go to rails s or rake db:migrate i get the following error Cannot load such file bcrypt_ext.
My ruby version is 2.2.1 my rails version is 4.2.0 and the bcrypt version is 3.1.10. All the gems install correctly when i run bundle install however whenever i try to rake it gives me that error. Any help would be greatly appreciated

You need to use what it says here: https://www.alib.jp/entries/bcrypt_ext_load_error_on_ruby21x
C:\> gem install --no-ri --no-rdoc bcrypt
C:\> cd (path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri
C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> ruby extconf.rb
C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> make
C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> make install

I meet the same problem in Window 8.1 64bit , Ruby 2.3.3 64bit , Rails 4.2.10.
My quick solution :
Step 1 : Remove all bcrypt in gem : gem uninstall bcrypt ( choose option 3 if existed (remove all))
Step 2 : Install bcrypt again : gem install bcrypt
Then check version of bcrypt : gem list bcrypt
Step 3 : In Gemfile of your project, add : gem 'bcrypt', '3.1.11', platforms: [:ruby, :x64_mingw]
notice : change the suitable version of your bcrypt (my version : 3.1.11)
Step 4 : Run command in the path of your project : bundle install
Step 5 : Remove the unneeded bcrypt :
Run command : gem uninstall bcrypt
You can see some version of bcrypt , you should keep one version : bcrypt-[your-version] . (Remove all version : bcrypt-[your-version]-x64-mingw32 . In mycase , remove : bcrypt-3.1.11-x64-mingw32)
Restart Rails sever , done
I think this proplem because when we install bcrypt , we didn't specify 64bit or 32bit , it is not compatible with window or ruby ( 64bit or 32bit )

For Windows 10, bcrypt 3.1.11 now works, checked in 24144
steps:
shut down all rails servers
uninstall all versions of bcrypt
manually install v3.1.1 (gem install bcrypt -v '3.1.11')
update gem files of projects
current versions
ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32]
OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.10586 N/A Build 10586

The dirty quick workaround is to install the mri version with
gem install bcrypt --platform=ruby
worked for me.
Fetching: bcrypt-3.1.11.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed bcrypt-3.1.11
source:
topac commented on Apr 17, 2015
https://github.com/codahale/bcrypt-ruby/issues/116

Rich Peck solution worked for me with a small update. Make sure the devkit is included in the environment path.(Check it by typing path in the command prompt) If its not included,you need to add the devkit/bin and devkit/mingw/bin paths to your PATH var.
Otherwise - make: x86_64-w64-mingw32-gcc: Command not found - error will be thrown while you make the file.
Once the error is fixed, then i am able to make the file and the bcrypt_ext issue is solved.

Most likely the compiled gem binaries don't contain binaries for Ruby 2.2.1. This is because there is a problem with cross-compiling Ruby with a Windows target. See this answer for more details.
The best alternative is to downgrade to Ruby 2.1.5.
You can try to compile the gem yourself, but that's a totally different beast. In some cases, like nokogiri, it's not even possible.

Related

"fat free crm" installation failling on Windows 10

I am trying to install fat free crm on a Windows 10 machine, but so far I have been unsuccessful. This is my latest attempt. Any help will be greatly appreciated.
Running bundler install gives me these messages:
Bundler 2.3.7 is running, but your lockfile was generated with 2.3.10. Installing Bundler 2.3.10 and restarting using that version.
Fetching gem metadata from https://rubygems.org/.
Fetching bundler 2.3.10
Installing bundler 2.3.10
Fetching gem metadata from https://rubygems.org/.........
Lots of successfully installed gems later:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/libv8-node-16.10.0.0/ext/libv8-node
C:/Ruby31-x64/bin/ruby.exe -I C:/Ruby31-x64/lib/ruby/3.1.0 -r
./siteconf20221119-16700-fgt0qd.rb extconf.rb
creating Makefile
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/libv8-node-16.10.0.0/ext/libv8-node/builder.rb:12:in
`build_libv8!': failed to download node 16.10.0 (Libv8::Node::BuilderError)
from
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/libv8-node-16.10.0.0/ext/libv8-node/location.rb:30:in
`install!'
from extconf.rb:9:in `<main>'
==== in
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/libv8-node-16.10.0.0/ext/libv8-node
==== running
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/libv8-node-16.10.0.0/libexec/download-node
extconf failed, exit code 1
My node version is v18.12.1, by the way. (Do I need an older one?)
Anyway, here is the exact sequence of actions before running bundler install inside my local git clone of fat_free_crm:
First, the repository I am using:
https://github.com/fatfreecrm/fat_free_crm
My Ruby version:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]
For a fresh start, I uninstall all gems, including rails:
gem uninstall -aIx
The latest commit on the bin folder says: Upgrade to Rails 6 so I install the latest rails 6 version on my machine:
gem install rails -v 6.1.7
I clone the repository from github:
git clone https://github.com/fatfreecrm/fat_free_crm.git
Since I am using sqlite3 for this, I comment out all other db gems in the Gemfile and only leave this one:
gem 'sqlite3', '~> 1.4.0'
Then, I copy database.sqlite.yml into database.yml.
Then, I run bundler install from within the directory fat_free_crm, which gives me this:
Ensure you have either installed the shared-mime-info package for your distribution, or
obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location of that file.
I (hopefully) solved that problem with this stackoverflow solution: Error installing ruby on rails on windows 10
Afterwards, I run bundler install again, which gives the error messages that I mentioned at the top of my description.
Any help will be greatly appreciated.
P.S.: I am trying to get back into Ruby on Rails after a long break, so please forgive me, if I made any stupid mistakes.

In a Ruby on Rails installation, what is causing webrick to be outdated and why `gem i webrick` can update it?

I have a new Mac computer and installed rails on it, and then I tried out the command
gem outdated
for some reason, it showed one of the gems outdated:
webrick (1.4.2 < 1.6.0)
I wonder why it is outdated on the first installed, and when I did
sudo gem install webrick
it actually installed 1.6.0 onto the system. Doesn't it require gem update instead of install to update something? How come install also updated it?
Not exactly, gem install GEM_NAME will install the last version available if you don't specify a version when installing, and you can have more than 1 version of the same gem on your machine.
you can run gem environment, and check where gems are installed, go to that folder and you will see both version gems folder there.
so when you create a rails project for example and add a specific version of a gem in the gemfile and another version on another project, you can have both without problems

An error occurred while installing autoprefixer-rails (6.2.2). Additionally it say's "autoprefixer-rails requires ruby version >= 2.0. "

Im facing this problem when i'm installing bunder using command "bunlde install"
Initially i tried solving this issue by using following command
gem install autoprefixer-rails -v '6.2.2'
but again it said "autoprefixer-rails requires ruby version >= 2.0."
when i type
"ruby -v", my ruby version shows 2.3.0.
Next i have tried adding
ruby '2.3.0' to my gem file, then there was a conflict saying your ruby version is 1.9.3 but your gem file has 2.3.0
Need help how to proceed further.
Change your ruby version in the system first. If you using rvm then use following command.
rvm use 2.3.0
If you don't have it then install it by following command
rvm install 2.3.0
Delete the Gemfile.lock file and run
bundle install
Hopefully it will work. Thank you

rails version not found, even though it's available in the rubygems

I wanted to switch from Rails 4.1.1 to Rails 3.2, because I heard some specific features I am interested in work best in 3.2.
gem install --http-proxy http://web-proxy:8088 rails –v '3.2.18' --no-rdoc --no-ri - this command didn't work, no such version (3.2.18) is available so rails 4.1.1 (most recent version) was (re)installed automatically.
Here is the reason:
Fetching: rails-4.1.1.gem (100%)
Successfully installed rails-4.1.1
ERROR: Could not find a valid gem 'ûv' (>= 0) in any repository
ERROR: Could not find a valid gem '3.2.18' (>= 0) in any repository
1 gem installed
So: I go to rubygems.org, check list of available rails versions and I see that 3.2.18 (https://rubygems.org/gems/rails/versions/3.2.18) is actually an available version. What am I doing wrong. Why is 3.2.18 not found, if it's on the rubygems site?
I really need Rails 3.2 to have an issue fixed that works poorer in newer Rails versions (according to research in the internet) - many thanks in advance
It seems like you copied and pasted parts of your command resulting to non ASCII characters.
In particular, the dash (-) seems to be the issue here. Try again with this:
gem install --http-proxy http://web-proxy:8088 rails -v '3.2.18' --no-rdoc --no-ri
The error message partly gives it away (at least it points to encoding issues) in Could not find a valid gem 'ûv' (>= 0).
First you uninstall latest rails version in your gem. Then install rails 3.2 in your local system and bundle it in your project terminal. And then edit in your gem file as
gem 'rails','~3.2'
now restart server and run it

Installe RMagick gem locally but unable to do the same using bundle install [windows 7(32 bit)]

I was able to install the rmagick-2.6.0-x86-mswin32.gem gem in my windows 7 machine using gem install command and I got the following success messages:
D:\dev>gem install rmagick-2.6.0
Successfully installed rmagick-2.6.0-x86-mswin32
1 gem installed
Installing ri documentation for rmagick-2.6.0-x86-mswin32...
Installing RDoc documentation for rmagick-2.6.0-x86-mswin32...
But when I try to install using bundle install (with the same version mentioned in the Gemfile) it throws the following error messages:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
. D:/Ruby187/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.2... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.6.0. Can't find Magick-config in D:\Ruby187\bin;D:\Ruby1
....
I already have ImageMagick installed and its paths included in the env vars, but the paths mentioned in the error message above seem to be different somehow(?!)
When i type rails -v now, I get the following message:
D:\dev>rails -v
←[31mCould not find gem 'rmagick (= 2.6.0) x86-mingw32' in the gems available on
this machine.←[0m
←[33mRun `bundle install` to install missing gems.←[0m
Do i need to make any other changes/ setups to install this gem with my gemfile using bundle install?
Also I actually need an earlier gem '2.5.2' but the win32 specific version of that gem does not seem to available, is there any way to get it?
I need to do this development on windows for the moment so I can switch to any other OS for the moment. Also since this is a legacy app I am working on, I will need to stick with rmagick and can't switch to any other solution.
Env info:
Ruby: 1.8.7
Rails:
Please help!
Many thanks.
Hey have you tried installing Devkit, for installing gems with native extensions on windows.
Try the steps in the following link, and check whether the Devkit has been installed in your path variable, try opening a new command shell and install the gems.
http://doelsengupta.blogspot.in/2010/10/unable-to-download-gem-with-native.html
all the best!!
I kept having this problem but was finally able to get around it using the following solution from #Martin Cohen - after modifying the gemspec file as he has suggested and rebuilding it, i was able to successfully install rmagick gem using bundle install...
https://stackoverflow.com/a/5595274/1865578
cheers!

Resources