Why can't Elixir find __DIR__? - elixir-mix

I'm trying to run mix test for elixir-json. When I do, I get
** (CompileError) /Users/me/Projects/elixir/json/test/json_test.exs:1: function '__DIR__'/0 undefined
/usr/local/Cellar/erlang-r16/R16B01/lib/erlang/lib/parsetools-2.0.9/include/yeccpre.hrl:128: :elixir_parser.yecctoken_end_location/1
/usr/local/Cellar/erlang-r16/R16B01/lib/erlang/lib/parsetools-2.0.9/include/yeccpre.hrl:113: :elixir_parser.yeccpars1/7
/usr/local/Cellar/erlang-r16/R16B01/lib/erlang/lib/parsetools-2.0.9/include/yeccpre.hrl:56: :elixir_parser.yeccpars0/5
src/elixir_translator.erl:17: :elixir_translator.forms/4
src/elixir_translator.erl:27: :elixir_translator.forms!/4
src/elixir_compiler.erl:25: :elixir_compiler.string/2
/private/tmp/elixir-pvTm/elixir-0.8.2/lib/elixir/lib/code.ex:229: Code.require_file/2
/private/tmp/elixir-pvTm/elixir-0.8.2/lib/elixir/lib/kernel/parallel_require.ex:48: Kernel.ParallelRequire."-spawn_requires/5-fun-0-"/5
I installed Elixir via brew according to the instructions.
What's going wrong?

The elixir version you have installed doesn't have the __DIR__ macro.
I suggest you install elixir using asdf, it's a really great Elixir version tool, and you can install any version of the language you'd like.
https://github.com/asdf-vm/asdf
asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git

Related

Pybind11 - Failing in Travis / Virtualenv

My Pybind project seems to be compiling fine on my system, but when I perform unit testing on travis, it throws the following error:
-- Found PythonInterp: /opt/pyenv/shims/python3.7 (found version "1.4")
CMake Error at 3rdparty/pybind11/tools/FindPythonLibsNew.cmake:95 (message):
Python config failure:
pyenv: python3.7: command not found
The `python3.7' command exists in these Python versions:
3.7
3.7.1
This seems to be something to do with virtualenv which I have never used. I currently have no idea how to solve this issue, and given that its in a travis instance, i'm not sure how to recreate it on my system so I may fix it
What is happening in your case is that the wrong Python version is being used by travis.
For example, if you are using Ubuntu 16.04 (Xenial) in your .travis.yml configuration, you have to specify the version you want for Python when you call CMAKE.
For example, something like
cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$(python-config --prefix)/bin/python3.5 -DPYTHON_LIBRARY=$(python-config --prefix)/lib/libpython3.5m.so -DPYTHON_INCLUDE_DIR=$(python-config --prefix)/include/python3.5m ..
Other versions of Ubuntu will have different versions of Python.
References:
https://github.com/vgc/vgc/issues/42
https://github.com/pybind/pybind11/issues/99#issuecomment-207782425
just to add to Murilo's answer, you could use Miniconda as a workaround as well, and configure CMAKE in a similar way by just changing the paths to the ones in your Miniconda env. I ran into issues when using multiple jobs for different Ubuntu distributions (xenial and bionic), which had somewhat different paths to the python libraries and headers.
Here there's a link to a travis with miniconda snippet which you could use to setup miniconda along a travis build.
You can then use the following CMAKE configuration in your travis.yml file (note that the environment with name travis_env was created with python=3.6):
script:
# ...
- cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=$HOME/miniconda/envs/travis_env/bin/python3.6 -DPYTHON_LIBRARY=$HOME/miniconda/envs/travis_env/lib/libpython3.6m.so -DPYTHON_INCLUDE_DIR=$HOME/miniconda/envs/travis_env/include/python3.6m ..
# ...

Missing core.lua installing redis-lua for lua5.1

I'm trying to install a redis client for Lua5.1, any client will do.
I installed redis-lua(https://github.com/nrk/redis-lua)
and
LuaSocket(http://w3.impa.br/~diego/software/luasocket/),
But when I try to get a "redis.connect" in my lua script, it says "could not find module "socket.core" .
And I find that there is no core.lua under /usr/local/share/lua/5.1/socket directory, how should I solve this?
p.s. I'v tried many redis clients for lua, and because I'm not familia with lua and luarocks, non of them works, always missing some dependencies that I cannot find, or got error when compiling with gcc.

Where are the modules installed using luarocks

I am trying to require a module I downloaded using luarocks using
require "lualogging"
but lua (and I!) cannot find where this module was downloaded to. Here is what I did
I have used apt-get to install luarocks, and then I ran
sudo luarocks install lualogging
I then ran
luarocks list
and received the following output
Installed rocks:
lualogging
1.3.0-1 (installed) - /usr/local/lib/luarocks/rocks
luasocket
3.0rc1-1 (installed) - /usr/local/lib/luarocks/rocks
Natural this led me to believe that lualogging was located in /usr/local/lib/luarocks/rocks, but running this command
find /usr/local/lib/luarocks/rocks "lualogging.lua"
returned nothing. What am I doing wrong here? This may be related, but I cannot find what my LUA_PATH environment variable is so it may be that it was never set? I'd like to be able to run require "lualogging" from any file regardless of where it is located in the filesystem, and then log to my heart's content. But I can't even find where lualogging.lua exists...
Run luarocks show lualogging. It will list all modules and where they are.
It should be
require "logging"
not
require "lualogging"

Installing ejabberd-websockets module in Mac OSX

I have downloaded ejabberd and even done a :
sudo port install ejabberd
After this, I am trying to install the ejabberd-websocket module from here : https://github.com/superfeedr/ejabberd-websockets
However, try as I might I am not able to install it by issuing :
./build.sh
This is the error that I am getting :
Recompile: src/mod_websocket
src/mod_websocket.erl:22: can't find include file "ejabberd.hrl"
src/mod_websocket.erl:23: can't find include file "jlib.hrl"
src/mod_websocket.erl:36: undefined macro 'DEBUG/2'
src/mod_websocket.erl:16: function process/2 undefined
src/mod_websocket.erl:14: Warning: behaviour gen_mod undefined
src/mod_websocket.erl:95: Warning: function validate_origin/1 is unused
src/mod_websocket.erl:171: Warning: function build_stream_end/0 is unused
I even have erlang as I installed it via macports. However, I am not able to install the module.
I am using Mac OSX Mountain Lion.
Any help would be great.
I can help you get around some of your issues. At least in my case, ejabber installed into a different location than this project expects. If you open Emakefile you will see it tries to include /usr/lib/ejabber/include, but in my case I had to remove the /usr part so it is just /lib/ejabberd/include. It may not be exactly the same in your case, but you just need to find your ejabber installation and make sure those directory paths match.
My Emakefile for reference
{'src/mod_websocket', [{outdir, "ebin"},{i,"/lib/ejabberd/include"},{i,"/lib/ejabberd/include/web","src"}]}.
{'src/ejabberd_xmpp_websocket', [{outdir, "ebin"},{i,"/lib/ejabberd/include"},{i,"/lib/ejabberd/include/web","src"}]}.
{'src/ejabberd_websocket', [{outdir, "ebin"},{i,"/lib/ejabberd/include"},{i,"/lib/ejabberd/include/web","src"}]}.
I also had to modify the build.sh script, but I don't think it solved any of my problems
#!/bin/sh
erl -pa /lib/ejabberd /lib/ejabberd/include /lib/ejabberd/ebin -pz ebin -make

How do I use xsltproc command-line tools on Heroku

In my Ruby on Rails application, I am using xsltproc command-line tools. These work on my development machine, but are not working on Heroku, the deployment platform I am using. I asked Heroku support a question about it, and here is what they said:
Hi– can you try compiling xsltproc as a standalone static binary and deploy that as part of your application?
If I knew what that meant, I probably wouldn't be here. I am guessing it means make a file with all the xsltproc code and call that for the xsltproc commands. I have no idea how to do that. Can anyone help?
If anyone wants to use xsltproc command-line tools on Heroku, don't do it. I was able to use the Nokogiri gem, along with the built in XPath functions to do everything I need.

Resources