Skip to content
Sign upLog in
← Back to Community

Can't use bcrypt

Profile icon

Dear All

I am learning Ruby on Rail and using Repl to run my code, I am trying to run the following code and I am getting an errors (Please check the error below) so I appreciate your help:

My code:

require 'bundler/inline'
gemfile true do
source ''
gem 'bcrypt'

require 'bcrypt'

my_password = BCrypt::Password.create("my password")


my_password.version #=> "2a"
my_password.cost #=> 12
my_password == "my password" #=> true
my_password == "not my password" #=> false

my_password ="$2a$12$K0ByB.6YI2/OYrB4fQOYLe6Tv0datUVf6VZ/2Jzwm879BW5K1cHey")

my_password == "my password" #=> true

Error Capture

my_password == "not my password" #=> false

Error Capture

~/test$ ruby main.rb
Traceback (most recent call last):
10: from main.rb:3:in <main>' 9: from /var/lib/gems/2.5.0/gems/bundler-2.2.7/lib/bundler/inline.rb:54:ingemfile'
8: from /var/lib/gems/2.5.0/gems/bundler-2.2.7/lib/bundler/settings.rb:115:in temporary' 7: from /var/lib/gems/2.5.0/gems/bundler-2.2.7/lib/bundler/inline.rb:61:inblock in gemfile'
6: from /var/lib/gems/2.5.0/gems/bundler-2.2.7/lib/bundler/settings.rb:115:in temporary' 5: from /var/lib/gems/2.5.0/gems/bundler-2.2.7/lib/bundler/inline.rb:62:inblock (2 levels) in gemfile'
4: from /var/lib/gems/2.5.0/gems/bundler-2.2.7/lib/bundler/installer.rb:24:in install' 3: from /var/lib/gems/2.5.0/gems/bundler-2.2.7/lib/bundler/installer.rb:72:inrun'
2: from /var/lib/gems/2.5.0/gems/bundler-2.2.7/lib/bundler/process_lock.rb:9:in lock' 1: from /var/lib/gems/2.5.0/gems/bundler-2.2.7/lib/bundler/process_lock.rb:9:inopen'
/var/lib/gems/2.5.0/gems/bundler-2.2.7/lib/bundler/process_lock.rb:9:in `initialize': Read-only file system @ rb_sysopen - /var/lib/gems/2.5.0/bundler.lock (Errno::EROFS)

Profile icon