LoadError: cannot load such file - require_relative on modules - ruby-on-rails

I have written an initializer in config/initializers/my_ini that has a require_relative statement: require_relative "../../lib/ryze/ryze"
I have the required file in app/lib/ryze/ryze.rb
However, now when I try to boot the app I get LoadError: cannot load such file -- /app/lib/ryze/ryze on the require_relative line of the initializer my_ini
Folder structure:
|-app
| |_config
| |_initializers
| |-my_ini.rb
|
|-lib
| |_ryze
| |-ryze.rb
note: I am using this application in docker
What are some options I could try to debug this?

Yeah, I was trying to require my lib from inside the app folder, while in fact, the lib folder I was trying to reach should be in the same level as app not inside.
once I moved lib out, it worked!

Related

Error: Unable to resolve module ./index from /Users/tandamangreen/Desktop/nbaCup/nbaClient/.:

Error: Unable to resolve module ./index from /Users/tandamangreen/Desktop/nbaCup/nbaClient/.:
None of these files exist:
* index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
* index/index(.native|.ios.js|.native.js|.js|.ios.json|.native.json|.json|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx)
at ModuleResolver.resolveDependency (/Users/tandamangreen/Desktop/nbaCup/nbaClient/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:136:15)
at DependencyGraph.resolveDependency (/Users/tandamangreen/Desktop/nbaCup/nbaClient/node_modules/metro/src/node-haste/DependencyGraph.js:231:43)
at /Users/tandamangreen/Desktop/nbaCup/nbaClient/node_modules/metro/src/lib/transformHelpers.js:129:24
at Server._resolveRelativePath (/Users/tandamangreen/Desktop/nbaCup/nbaClient/node_modules/metro/src/Server.js:1107:12)
at async Server.requestProcessor [as _processBundleRequest] (/Users/tandamangreen/Desktop/nbaCup/nbaClient/node_modules/metro/src/Server.js:450:37)
at async Server._processRequest (/Users/tandamangreen/Desktop/nbaCup/nbaClient/node_modules/metro/src/Server.js:406:9)
I had index.js inside the src folder and it should have been in the top level folder. Once I put it there I had no issues.
Make sure your startup source file is place in the correct directory, otherwise metro is not going to know where to find it.

Local references in imported Terraform module

I have TF modules on bitbucket in the terraform-modules project.
In my main module (in the azure/main_module directory) on bitbucket I have:
azure
|
+- sub_module
main.tf
main_module
main.tf
In main_module/main.tf I have the following file structure:
azure
|
+-general
|
+-main.tf
module "my_sub_module" {
source = "../azure/sub_module/"
...
}
Now, in another project, in another module I have:
module "credit" {
source = "git::bitbucket.org:myorg/terraform-modules.git//main_module"
...
}
I get the following error when running tf plan in the other project:
Error: Unreadable module directory
Unable to evaluate directory symlink: lstat
.terraform/modules/main_module/azure/azure: no such file or directory
Everything works when the local references are replaced with bitbucket references.
So it seems as though the main_module is imported, but then the local references in that project is are interpreted as local references in the importing project (the one with the general module) and then it can't find additional modules because it is searching in the wrong project?
Any ideas how this can be fixed, while still using local references in the imported project?

LuaJit won't find a library "lua-vips" installed via "luarocks"

I have this lua file:
-- test1.lua
--require "luarocks.loader"
vips = require "vips"
--vips = require "lua-vips"
local img = vips.Image.new_from_file("img1.jpg")
-- [...................]
It won't find the library "lua-vips" installed via "luarocks":
$ luajit test1.lua
luajit: error loading module 'vips' from file '/usr/local/lib/luarocks/rocks-5.3/':
cannot read /usr/local/lib/luarocks/rocks-5.3/: Is a directory
stack traceback:
[C]: at 0x0102caa660
[C]: in function 'require'
test1.lua:2: in main chunk
[C]: at 0x0102c3b8a0
Even after I add
export LUA_PATH="/usr/local/lib/luarocks/rocks-5.3/"
to ~/.profile, it won't.
The content of the directory luarocks -- lua-vips exists:
ls /usr/local/lib/luarocks/rocks-5.3/
lua-vips manifest
How how to fix this?
$ luarocks path
export LUA_PATH='/Users/my_user/.luarocks/share/lua/5.3/?.lua;/Users/my_user/.luarocks/share/lua/5.3/?/init.lua;/usr/local/share/lua/5.3/?.lua;/usr/local/share/lua/5.3/?/init.lua;/usr/local/Cellar/luarocks/3.0.1/share/lua/5.3/?.lua;/usr/local/lib/lua/5.3/?.lua;/usr/local/lib/lua/5.3/?/init.lua;./?.lua;./?/init.lua'
export LUA_CPATH='/Users/my_user/.luarocks/lib/lua/5.3/?.so;/usr/local/lib/lua/5.3/?.so;/usr/local/lib/lua/5.3/loadall.so;./?.so'
export PATH='/Users/my_user/.luarocks/bin:/usr/local/bin:/Users/my_user/.yarn/bin:/Users/my_user/.config/yarn/global/node_modules/.bin:/Users/my_user/.nix-profile/bin:/Users/my_user/.nvm/versions/node/v8.14.0/bin:/Users/my_user/.cargo/bin:/Users/my_user/.gem/ruby/2.5.1/bin:/Users/my_user/.rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/bin:/Users/my_user/.rubies/ruby-2.5.1/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/my_user/go/bin'
Your problem is that LUA_PATH doesn't work the same way PATHs usually work.
You don't give it a directory, but a template string with an ? representing the name of the library to load.
So, for example, if you want to find files in the /path/to/libs/ directory, you'd write "/path/to/libs/?.lua;/path/to/libs/?/init.lua" for the path.
If you literally add "/usr/local/lib/luarocks/rocks-5.3/", Lua will try to load that directory as a Lua file, which causes your error.
Remove that environment variable and tell us what error you get.
Also keep in mind that adding something to .profile requires logging out and back in again for the changes to take effect (or to source ~/.profile in every new shell you open)

Julia use of JLD: WARNING: Module HDF5 uuid did not match cache file

When I run using JLD I get the following warnings:
INFO: Recompiling stale cache file C:\Julia\PkgDir\lib\v0.4\JLD.ji for module JLD.
WARNING: Module HDF5 uuid did not match cache file
This is likely because module HDF5 does not support precompilation but is imported by a module that does.
WARNING: deserialization checks failed while attempting to load cache from C:\Julia\PkgDir\lib\v0.4\JLD.ji
INFO: Precompiling module JLD...
INFO: Recompiling stale cache file C:\Julia\PkgDir\lib\v0.4\JLD.ji for module JLD.
WARNING: Module HDF5 uuid did not match cache file
This is likely because module HDF5 does not support precompilation but is imported by a module that does.
__precompile__(true) but require failed to create a precompiled cache file
If I then run say:
A=ones(40)
save("c:\\OneDrive\\Model\\myfile.jld", "A", A)
I get the error:
UndefVarError: save not defined in include_string at loading.jl:288 in eval at
C:\Julia\PkgDir\v0.4\Atom\src\Atom.jl:3 [inlined code] from
C:\Julia\PkgDir\v0.4\Atom\src\eval.jl:39 in anonymous at
C:\Julia\PkgDir\v0.4\Atom\src\eval.jl:108 in withpath at
C:\Julia\PkgDir\v0.4\Requires\src\require.jl:37 in withpath at
C:\Julia\PkgDir\v0.4\Atom\src\eval.jl:53 [inlined code] from
C:\Julia\PkgDir\v0.4\Atom\src\eval.jl:107 in anonymous at task.jl:58
I'm using Atom 1.8.0 and Julia 0.4.7. I'm using JLD as, to the best of my knowledge, it's the only pkg that allows me to write variables to file and preserve all of their attributes.
I had a similar issue with JLD at one point and running Pkg.update() fixed it. Updating to the latest stable Julia version before running the package update could also be helpful.

Command 'rebar doc' is inconsistent

First of all, 'rebar doc' works sometimes and sometimes not. It is strange.
Rebar version which I'm using is 2.5.1
My folder structure is:
Header_Directory
1.1 apps
1.1.1 sub_dir_1
1.1.2 sub_dir_2 / include
1.1.3 sub_dir_3
1.2 deps
1.3 confs
rebar.config
Modules in sub_dir_3 also use some include files from sub_dir_2/include folder.
The error I get when I use the command rebar doc is:
.sub_dir_3/src/my_log_worker.erl, in module header: at line 9: file
not found: some.hrl edoc: skipping source file
'sub_dir_3/src/my_log_worker.erl': {'EXIT',error}. edoc: error in
doclet 'edoc_doclet': {'EXIT',error}. ERROR: doc failed while
processing /home/learn/header_directory/apps/sub_dir_3: {'EXIT',error}
I do 'rebar clean' and then 'rebar compile' prior to 'rebar doc'
Also,when I do it in erl shell, I get error.
edoc:file("some_log_worker.erl", []).
edoc: error reading file 'some_log_worker.erl'.
** exception exit: {error,enoent}
in function edoc:read_source/2 (edoc.erl, line 664)
in call from edoc_extract:source/3 (edoc_extract.erl, line 52)
in call from edoc:read/2 (edoc.erl, line 537)
in call from edoc:file/2 (edoc.erl, line 116)
Is there any way by which I can include my hrl file either in rebar.config or edoc options?
I have '{edoc_opts, [{ i, "apps/sub_dir_3/include" }]}.' in rebar.config, still of no help.
It looks like you didn't follow the rebar/OTP conventions:
OTP Conventions
Rebar expects projects to follow the OTP conventions as described in
the OTP Design Principles document: Applications
An application should consists of the following set of directories:
src
ebin
priv
include
and have an application resource file: ebin/example_project.app or
src/example_project.app.src. In the later case, the
ebin/example_project.app file is generated from the
src/example_project.app.src one automatically during the compilation
phase.
Rebar & OTP convetions
I recommend you to move to that file organisation, it will be really much simpler to benefit from standard tools like rebar.
Yes, it is always in the best interest to follow the OTP principles. However, it worked for my app structure.
The only problem was because of #headerfile annotation in the erlang modules. Somehow, I don't know how to correctly use the #headerfile annotation.
Thanks for all the help. :)

Resources