The version file is at the toplevel dir in lib, which makes it not namespaced on the file system. Thus require "version" is really requiring dotenv_validator's version, despite the fact that this is unexpected. The solution that people have arrived at is to namespace files within a directory that matches the gem name. So, this movew lib/version.rb to lib/dotenv_validator/version.rb.
For a bit more context on this, I go into it here.
Here is a demonstration that requiring "version" winds up requiring this file:
Additionally, I built the gem to verify that this works as expected, and then saw that the built gem wound up in a pkg directory, which git was aware of. This seemed precarious b/c it would be easy enough to add and commit previous gems into the repo. So I also added pkg to .gitignore.
The version file is at the toplevel dir in
lib
, which makes it not namespaced on the file system. Thusrequire "version"
is really requiringdotenv_validator
's version, despite the fact that this is unexpected. The solution that people have arrived at is to namespace files within a directory that matches the gem name. So, this movewlib/version.rb
tolib/dotenv_validator/version.rb
.For a bit more context on this, I go into it here.
Here is a demonstration that requiring "version" winds up requiring this file:
Additionally, I built the gem to verify that this works as expected, and then saw that the built gem wound up in a
pkg
directory, whichgit
was aware of. This seemed precarious b/c it would be easy enough to add and commit previous gems into the repo. So I also addedpkg
to.gitignore
.I will abide by the code of conduct.