How to load Erlang modules conveniently - terminal

I am asking fellow Erlang developers how do they load specific modules in the erlang shell. I find it very cumbersome to:
open erlang shell
copy path of module -> /path/.../ to the shell
change all backslashes from path to \path\
run c(editedPath)
And this only for one module.
Can't erlang just be opened in a particular folder and load everything that is there? Or can't i move to target folder and from that terminal start erlang shell and load modules?
P.S I am using VS Code and it would be really helpful to just open the integrated terminal in target folder and start loading the modules on that relative path.

change all backslashes from path to `\path\
Why would anyone do that?
Or can't i move to target folder and from that terminal start erlang
shell and load modules?
Yes. That's what I do for messing around while learning erlang. But for larger projects, there's rebar3, which is erlang's package manager. rebar3 projects employ a specific directory structure for your own source code, and then rebar3 will fetch and compile imported packages as well as your source code with a single command.
Also, see the flags -pa and -pz for the erl command.

You need to read up a bit about the code server and how it handles the code path - see http://erlang.org/doc/man/code.html
Set up the code path (with absolute paths only) so that it points to one or more of your "ebin" directories containing .beam files - or set the ERL_LIBS environment variable to point out the parent directory of your Erlang apps, so that they get automatically added to the path.
Do not add "." to the path except if you're just playing around. For a non-toy application, you should generally never rely on the current working directory of the Erlang VM (since Erlang runs a number of independent processes, the idea of a global current directory is pretty shaky anyway).

Related

Clarify how installing Bazel on windows works?

So I'm following the install instructions for Bazel 2.0, and basically it seems like all I have to do is download the ".exe" file, add it to the path, and then I can use it from windows powershell (probably bash too, although I haven't tried). What I want to know is - does the ".exe" file do any manipulation of my system (outside of the obvious compiling work) or download anything else under the hood? I ask because I want to try it out while working on a restricted computer system, as I'm sure some of you have encountered before.
It will extract itself into the location where it also (unless configured otherwise) keeps its build output. By default this would be under current user's home directory. The location can be changed with --output_user_root parameter or TEST_TMPDIR environmental variable. You can check out the docs for more detailed description.
Adding to Ondrej K.'s answer:
Yes, you just download the .exe and add it to your PATH. Do not run it from Bash though, because it's broken. (I'm linking to the documentation at master as of 2020-02-28 and as of 2.1.0 being the most recent version. The current master will become the release doc for 2.2.0.)
Yes, Bazel will download stuff. This includes tools for the languages you build (e.g. Java), and also external dependencies of the project.
Yes, Bazel will write to disk even if you just run it once: as Ondrej K. wrote, it will extract itself to a directory.
Do not set TEST_TMPDIR to tell Bazel where to run. Setting this envvar will make Bazel believe it's running inside a test, and it will significantly reduce its resource use and change its behavior in subtle ways you probably don't want. (If you want to limit its resource use, you can do so with several flags, see --jobs and --local_ram_resources, --local_cpu_resources.)

MobaXTerm how to create your own plugin?

Problem
I see all these plugins from MobaXTerm, but I don't know how to make my own. I see no links to any tutorials or whatever. Is there even a way to do it?
What I really want (XY problem)
I want to create my own commands. I want these to be available on each server I go to and I don't want to add each of these to my bin and .bash_profile etc. I think plugin is the way to go.
Even more background
I am not that good in shell programming, but I can program java. I created a jar which handles my commands. So I have created my own linux script on my local environment to test all these things. They work, but I dont want to 'export' them to other servers. Seems like a bad idea to do.
MobaXterm plugins are just Windows or Cygwin executables packaged in a .mxt3 file which is just a standard ZIP archive with a specific structure.
Read this from the MobaXterm FAQ:
I would like to create a new plugin for MobaXterm. How can I do that?
Download an existing plugin file (for instance "Midnight commander")
Rename plugin extension from ".mxt3" to ".zip"
Open the ".zip" file You will notice that creating MobaXterm plugins only consists in putting the required commands (executables, libraries
and configuration files) into a ZIP file, keeping the same folders
tree than in MobaXterm ("/bin", "/lib", "/usr", "/etc").
If you want to add a simple Windows program (exe file), you will just have to copy the executable file into the "/bin" directory,
create the ZIP archive, rename it to ".mxt3" and put it in the same
directory than MobaXterm executable.
If you want to add a Linux program, you will have to get it from the Cygwin project or to recompile it using make, gcc, g++ or other
compilers that are available from the MobaXterm "Development" plugin.
Remember MobaXterm's terminal is just Cygwin, so you may be able to cross compile some packages within Moba by simply installing the necessary compiler tools.

QT Not including the correct library when running a build

I'm building a program Using Qt Creator 5.2.1 (32 bit) with Mingw. One of the dependencies of this program is the libcurl library.
QT was building the file properly, however, when running, it would throw an error 139.
After running the dependency walker on the binary, I noticed that the libcurl dll in turn depends upon another dll called "libeay32.dll".
I did the following:
Copied the my program along with all required libraries(including
libeay32.dll) externally to Qt and ran it (this was successful).
After that I tried running from within QT, but having the libeay32 library in the build before running (this was successful)
Logically, I presumed afterward, that if I put the path to the libeay32 prior to any other paths within my PATH variable, that It would pull the correct version of the lib (re: answer to question here). However this did not work, throwing the same error 139 (it's apparently not finding the library)
I know I could run and test my program by simply copying the file into my working directory, however, for information purposes, I was wondering;
Is there any way of doing this without having to copy this DLL?
My instinct would have been that fixing the Path to point to this firstly would have helped as this would ensure that the DLL is pulled used before any other occurrences that may be there in other dirs.
Note: In referring to the PATH variable, I mean both the SYSTEM path and checking for the PATH Qt uses (Qt adds a few dirs to the path)
Thanks in advance for any help.
Either you link static, or you have to ensure that your library is located in one of the following locations (http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586(v=vs.85).aspx#standard_search_order_for_desktop_applications):
The directory from which the application loaded.
The current directory.
The system directory. Use the GetSystemDirectory function to get the path of this directory.
The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched.
The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
The directories that are listed in the PATH environment variable. Note that this does not include the per-application path specified by the App Paths registry key. The App Paths key is not used when computing the DLL search path.

Using Google's ProtoBuf (and a .proto file) to create a Python API Library

I have the .proto file used in the open-source Android API (http://code.google.com/p/android-market-api/), and am having some trouble compiling the file to generate the .py.
I'm trying to follow the instructions here, https://developers.google.com/protocol-buffers/docs/pythontutorial , and am on the steps that are under the header "Compiling Your Protocol Buffers".
I've downloaded the compiler, protoc.exe. The readme says "To install, simply place this binary somewhere in your PATH," which I'm not understanding. I'm messed around with it for a while now, but can't think of how to proceed.
I'm quite the novice programmer, so please tell me if something isn't clear, or if I'm having some sort of fundamental misunderstanding... about anything. I'm on Windows 7 by the way.
Thanks!
if protoc.exe is not in the same directory you're calling it from, you need to add it to your PATH environment variable to be accessible from the calling directory when you're in the shell. open up a command shell and execute:
set PATH=%PATH%c:\directory\to\proto\executable;
then change directories over to where your source code is and execute the compilation line as instructed from the google page.
I had the same problem because it is not written that clear in the README.txt. What they mean is to:
1. take the protoc.exe and put it in the same folder with the other files of your project.
2. open the cmd to that directory and run: protoc --cpp_out=. myfile.proto
=> This will create the 2 new files in the folder with the files of your project, and then you can add them normally to your program.
This helped me: http://www.scriptol.com/programming/protocol-buffers-tutorial.php
This is for c++, but I guess it will be something similar for python; I guess you just have to change the command you are using in the cmd :)

How can I test my vim plugin?

Hi guys : I recently (accidentally) removed all folders/files from my .vim folder in mac os x (home directory).
I am trying to add in the Clojure Vim plugin (VimClojure) - its simply a folder which you are supposed to "drop into .vim/plugins".
I have added it, but I don't see any changes to the syntax highlighting when I launch vim. I'm not sure wether vim "sees" the plugin or not.
I'm on OS X .
Any ideas on how to debug the plugin ? In particular
1) How does VIM look for plugins ?
2) Are there files which need to be in $HOME/.vim/ ?
3) Is it sufficient to simply dump the unzip a new plugin file into $HOME/.vim/plugins when installing a standard vim plugin ?
Thanks
About debugging: in order to see whether vim has loaded your plugin you can use :scriptnames and also breakadd file /path/to/your/plugin (or breakadd file *your_plugin_name.vim: I never used absolute paths so I do not know what breakadd will do in this case). Other questions:
Described in :h initialization, precisely :h load-plugins.
Vim does not need any files at all (except vim executable, used shared libraries, dynamic linker and the kernel of course).
Follow installation instructions. Normally plugins are either extracted to ~/.vim or distributed as a singe file that should go to either ~/.vim/plugin (no s!), ~/.vim/colors, ~/.vim/ftplugin or such. I guess you should try to extract it to ~/.vim/plugin, but if archive contains some special directories like plugin/, ftplugin/, colors/, after/ (see /usr/share/vim/vim73 for a list) it is likely that it should go to ~/.vim. Also consider using vim-addon-manager, if plugin was posted on vim.org VAM is likely to be able to install it.
A few points.
How does vim look for plugins? See :help startup so see where and when vim looks for files to load.
Not really. Anything there is just personal customization. Vim will run fine without a .vim folder.
That all depends on the plugin. It sounds to me like the VimClojure plugin may be a little misleading. Do you have a link to the source you are using?
In any case, the first step I always take when attempting to debug a script is check the output of :scriptnames. This command will show you what scripts vim has loaded for the current session. If you see none of the files shipped with VimClojure, you probably made a mistake during the installation.
Another tip is that you really should look in to using a plugin manager such as vundle or vim-addon-manager, or at least the runtimepath manager pathogen. This seems to be the way of the future for vim configuration these days and it makes installing and managing plugins much easier. They also help to keep your .vim folder clean and organized.
The VimClojure directory should either be extraction on top of your .vim folder, or in a bundle folder if your using something like pathogen (which you should!). If you're starting from scratch, consider starting with vimclojure-easy (not to toot my own horn) which is a basic, full install of VimClojure with instructions.

Resources