OpenResty require cannot find modules - module

After Apache has failed me miserably, I decided to go the OpenResty route.
So far, the Lua code is executing, however I opted to separate the generation in to multiple modules, to make the code more readable.
-- Define modules table
local modules = {
head = require("head"),
header = require("scripts.header"),
leftNav = require(".scripts.leftnav")
}
I've tried several methods of requiring files;
- I've taken one file out of the /scripts/ directory, and moved it to the root directory, file cannot be found
- I've tried referencing the /scripts/ directory with/out a period beforehand
and all is to no avail. The modules simply aren't found.
Is there some kind of special trick I need to find these files?
Here is an excerpt from the error log:
stack traceback:
coroutine 0:
[C]: in function 'require'
./html/mailarchive/index.lua:10: in function <./html/mailarchive/index.lua:1>, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
2017/05/12 10:26:13 [error] 113864#120792: *14 lua entry thread aborted: runtime error: ./html/mailarchive/index.lua:10: module 'head' not found:
no field package.preload['head']
no file './site/lualib/head.lua'
no file './site/lualib/head/init.lua'
no file './lualib/head.lua'
no file './lualib/head/init.lua'
no file '.\head.lua'
no file 'C:\nginx\lualib\head.lua'
no file 'C:\nginx\lua\head.lua'
no file 'C:\nginx\lua\head\init.lua'
no file 'C:\Program Files (x86)\Lua\5.1\lua\head.luac'
no file './site/lualib/head.so'
no file './lualib/head.so'
no file '.\head.dll'
no file 'C:\nginx\lualib\head.so'
no file 'C:\nginx\head.dll'
no file 'C:\nginx\loadall.dll'
stack traceback:
coroutine 0:
[C]: in function 'require'
./html/mailarchive/index.lua:10: in function <./html/mailarchive/index.lua:1>, client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost", referrer: "http://localhost/"

After some more researching, I found that using OpenResty, the period ( . ) doesn't refer to the current directory the executing script is located in, rather it refers to the directory that nginx is working in - in my case C:\nginx.
With this in mind, changing my resource locators from:
require(".scripts.head")
require(".scripts.header")
(...)
to
require(".html.mailarchive.scripts.head")
require(".html.mailarchive.scripts.header")
(...)
did the trick.
The new paths correlate to C:\nginx\html\mailarchive\scripts\head.lua, etc.

Related

XCode: The file “[APP NAME].app” couldn’t be opened because there is no such file

For context, I am encountering this immediately after resolving this issue:
Xcode error: unable to create directory '/[PATH_TO_APP]/[APP_NAME].app' (in target '[TARGET]' from project '[PROJECT]')
Here is the full error details text (with redactions in [] for privacy):
Details
The file “[APP NAME].app” couldn’t be opened because there is no such file.
Domain: NSCocoaErrorDomain
Code: 260
Failure Reason: The file doesn’t exist.
User Info: {
NSFilePath = "/[APP NAME].app";
}
--
The operation couldn’t be completed. No such file or directory
Domain: NSPOSIXErrorDomain
Code: 2
Failure Reason: No such file or directory
--
System Information
macOS Version 10.15.5 (Build 19F101)
Xcode 11.5 (16139)
Running ls -l in the project folder shows the [APP NAME].app now present, but navigating to the same location and selecting the file in Finder shows a "crossed out circle" over the app's icon. Removing the file and building again results in the same thing. I've also tried renaming the project and restarting, etc, to no avail.
NSFilePath = "/[APP NAME].app" feels like a missing or misspelled environment variable.
If the build expects custom environment variable like $(MyBuildDir) to be defined, when it's not, then running a command with $(MyBuildDir)/[APP NAME].app would result in "/[APP NAME].app"
The same is true for if the environment variable misspelled. For example, using $(UBILD_DIR)/[APP NAME].app instead of BUILD_DIR would result in "/[APP NAME].app"

Chef, Apache2 cookbook ressource fails to find service[apache2] when called from a custom resource

In my custom chef cookbook (located at https://github.com/sanguis/chef-omeka/tree/lwrp).
I am calling the Apache2 resource web_app from inside a custom resource (LWRP) that is being called from the custom solo.rb recipe.
include_recipe 'apache2'
web_app url do
server_name url
server_aliases aliaes
cookbook_name 'apache2'
docroot dir
allow_override 'All'
directory_index 'false'
# notifies :reload, 'service[apache2]', :delayed
end
This this returns an error:
[#] [2016-02-23T23:02:31+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[#] [2016-02-23T23:02:31+00:00] ERROR: instanceomeka.dev had an error: Chef::Exceptions::ResourceNotFound: resource execute[a2enmod headers] is configured to notify resource service[apache2] with action reload, but service[apache2] cannot be found in the resource collection. execute[a2enmod headers] is defined in /tmp/kitchen/cache/cookbooks/apache2/definitions/apache_module.rb:35:in `block in from_file'
However when I call the same resource from directly inside of a custom recipe here (line 126) it works.
My run list is bellow
# - recipe[build-essential]
- recipe[php::default]
- recipe[apache2]
- recipe[apache2::mod_rewrite]
# - recipe[apache2::mod_expires]
- recipe[apache2::mod_ssl]
- recipe[apache2::mod_php5]
- recipe[omeka::default]
- recipe[omeka::solo]
attributes: # - recipe[build-essential]
- recipe[php::default]
- recipe[apache2]
- recipe[apache2::mod_rewrite]
# - recipe[apache2::mod_expires]
- recipe[apache2::mod_ssl]
- recipe[apache2::mod_php5]
- recipe[omeka::default]
- recipe[omeka::solo]
attributes:
machine_fqdn: omeka.dev
machine_fqdn_as_hostname: true
apache2:
listen_ports: ["80", "443"]
machine_fqdn: omeka.dev
machine_fqdn_as_hostname: true
apache2:
listen_ports: ["80", "443"]
This fails on both ubuntu 14.04 and centos7.
This is a known issue with few workarounds for the moment. The issue is that using the new custom resource system enforces use_inline_resources mode, which is 99% a great idea except for this. That mode creates an isolated run context inside the custom resource so it can't see "out" to the other resources for the purposes of notifications. The Poise helper library offers some tools to get around this, but with Chef core the only major workaround is the super-unsupported (i.e. this might break without a major release):
web_app url do
# ...
notifies :reload, Chef.run_context.resource_collection.find('service[apache2]')
end

How to include Lua module in build

I downloaded this Lua module and installed it with make. However, when I try to use it in my code, I get the following error:
VirtualBox:~/Downloads$ lua socket_test.lua
lua: socket_test.lua:1: module 'nixio.util' not found:
no field package.preload['nixio.util']
no file './nixio/util.lua'
no file '/usr/local/share/lua/5.1/nixio/util.lua'
no file '/usr/local/share/lua/5.1/nixio/util/init.lua'
no file '/usr/local/lib/lua/5.1/nixio/util.lua'
no file '/usr/local/lib/lua/5.1/nixio/util/init.lua'
no file '/usr/share/lua/5.1/nixio/util.lua'
no file '/usr/share/lua/5.1/nixio/util/init.lua'
no file './nixio/util.so'
no file '/usr/local/lib/lua/5.1/nixio/util.so'
no file '/usr/lib/i386-linux-gnu/lua/5.1/nixio/util.so'
no file '/usr/lib/lua/5.1/nixio/util.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
no file './nixio.so'
no file '/usr/local/lib/lua/5.1/nixio.so'
no file '/usr/lib/i386-linux-gnu/lua/5.1/nixio.so'
no file '/usr/lib/lua/5.1/nixio.so'
no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
[C]: in function 'require'
socket_test.lua:1: in main chunk
[C]: ?
And the first line of my code:
local nixio = require "nixio", require "nixio.util"
Any help would be appreciated!
I see these options:
Try make install and hope that it works. Perhaps set some variable such as PREFIX nothing.
Manually move dist/usr/local/share/lua/5.1/nixio to /usr/local/share/lua/5.1/nixio and dist/usr/local/lib/lua/5.1/nixio.so to /usr/local/lib/lua/5.1/nixio.so.
Add the dist paths to the environment: LUA_CPATH='dist/usr/local/lib/lua/5.1/?.so;;' and LUA_PATH='dist/usr/local/share/lua/5.1/?.lua;;'.
Add the dist paths in Lua: package.cpath='dist/usr/local/lib/lua/5.1/?.so;'..package.cpath and package.path='dist/usr/local/share/lua/5.1/?.lua;'..package.path.

CGI working directory (trying to load a template file)

I have a CGI-script which tries to load a template file. However, I get an error where the file location of the CGI-script itself is added to the path where I try to load the template:
let template_string = Jg_template.from_file "/home/d37433/templates/startpage.tmpl" in
Error:
file /home/d37433/public_html/cgi-bin//home/d37433/templates/startpage.tmpl not found
Is there an error in my Apache config? The same code worked on another machine of mine (unfortunately, I don't have access to it at the moment).
Solved by programmatically change the working directory inside the CGI script.

Why my YII need have installed Oracle's Instant Client libraries?

I am playing with Yii framework and now I am investigating Yii Shell. But if I use this command:
yiic shell
I always get this error message:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_oci.so' - libclntsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0
libdc1394 error: Failed to initialize libdc1394
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_oci.so' - libclntsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0
Error: index.php does not exist or is not an entry script file.
It is strange for me, because I am gonna to use only mySQL drivers, so why Oracle now? Any idea?
Many thanks for your replies!
Jakub
Please install Oracle client and Open your php.ini, search for oci8.so and php_oci.so, in extensions section you should have something like extension=oci8.so and extension=pdo_oci.so, just comment it with ;. If You have extension=oci8_11g.so comment it as well"
Open your php.ini, search for oci8.so and php_oci.so, in extensions section you should have something like extension=oci8.so and extension=pdo_oci.so, just comment it with ;. If You have extension=oci8_11g.so comment this as well