8000 UUID No such file or directory ~/.gem/ruby/3.3.3/gems/ffaker-2.23.0/lib/ffaker/data/f_faker/uuid · Issue #550 · ffaker/ffaker · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

UUID No such file or directory ~/.gem/ruby/3.3.3/gems/ffaker-2.23.0/lib/ffaker/data/f_faker/uuid #550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
marko-avlijas opened this issue Oct 28, 2024 · 0 comments

Comments

@marko-avlijas
Copy link
marko-avlijas commented Oct 28, 2024

Description

When calling any method from UUID module from a new Rails app, const_missing raises Errno::ENOENT: No such file or directory.

Steps to Reproduce

  1. Create a new Rails application:
rails new ffaker-test \
  --minimal \
  --skip-action-mailer \
  --skip-action-mailbox \
  --skip-action-text \
  --skip-active-storage \
  --skip-hotwire \
  --skip-jbuilder \
  --database=sqlite3
  1. Change into the project directory:
cd ffaker-test
  1. Add the following gems to your Gemfile in the development and test groups:
group :development, :test do
  gem 'rspec-rails'
  gem 'ffaker'
end
  1. Install the gems:
bundle install
  1. Initialize RSpec:
rails generate rspec:install
  1. Create a new test file spec/ffaker_uuid_spec.rb:
require 'rails_helper'
require 'ffaker'

RSpec.describe 'FFaker UUID' do
  describe '.uuidv4' do
    it 'returns a string' do
      uuid = FFaker::UUID.uuidv4
      expect(uuid).to be_a(String)
    end
  end
end
  1. Setup database
rails db:create db:migrate
  1. Run the test:
bundle exec rspec

Error Output

Failures:
  1) FFaker UUID .uuidv4 returns a string
     Failure/Error: uuid = FFaker::UUID.uuidv4
     Errno::ENOENT:
       No such file or directory @ rb_sysopen - ~/.gem/ruby/3.3.3/gems/ffaker-2.23.0/lib/ffaker/data/f_faker/uuid
     # ~/.gem/ruby/3.3.3/gems/ffaker-2.23.0/lib/ffaker/utils/module_utils.rb:21:in `read'
     # ~/.gem/ruby/3.3.3/gems/ffaker-2.23.0/lib/ffaker/utils/module_utils.rb:21:in `const_missing'
     # ./spec/ffaker_uuid_spec.rb:7:in `block (3 levels) in <top (required)>'

Defect

def const_missing(const_name)
if const_name.match?(/[a-z]/) # Not a constant, probably a class/module name.
super(const_name)
else
mod_name = ancestors.first.to_s.split('::').last
data_path = "#{FFaker::BASE_LIB_PATH}/ffaker/data/#{underscore(mod_name)}/#{underscore(const_name.to_s)}"
data = k File.read(data_path, mode: 'r:UTF-8').split("\n")
const_set const_name, data
data
end
end

Environment

  • Ruby version: 3.3.3
  • FFaker version: 2.23.0
  • Rails version: latest

Expected Behavior

The FFaker::UUID.uuidv4 method should return a string representing a UUID.

Actual Behavior

The method fails with a "No such file or directory" error, indicating that FFaker is trying to load a data file that doesn't exist.

@marko-avlijas marko-avlijas changed the title UUID No such file or directory /#{HOME}/.gem/ruby/3.3.3/gems/ffaker-2.23.0/lib/ffaker/data/f_faker/uuid UUID No such file or directory ~/.gem/ruby/3.3.3/gems/ffaker-2.23.0/lib/ffaker/data/f_faker/uuid Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0