What network protocols does luarocks install use? - luarocks

I am running on a redhat box, behind a corporate firewall. I'm guessing that some of the protocols are getting blocked, but I'm a relative neophyte to git, and this is my first time ever using luarocks. It looks to me like luarocks is trying to use https:// so there should be no firewall issues.... But the error messages imply a firewall problem.
Here's what I know:
I do know that this git command works fine on my machine. git is able to clone the repository locally, and I can build luarocks from source.
git clone https://github.com/torch/luajit-rocks.git
But, this command fails:
luarocks install cwrap
Here is the output from the command
Installing https://raw.githubusercontent.com/torch/rocks/master/cwrap-scm-1.rockspec...
Using https://raw.githubusercontent.com/torch/rocks/master/cwrap-scm-1.rockspec... switching to 'build' mode
Initialized empty Git repository in /tmp/luarocks_cwrap-scm-1-8589/cwrap/.git/
github.com[0: 192.30.252.129]: errno=Connection timed out

LuaRocks uses LuaSocket and LuaSec when available to do HTTP and HTTPS, but apart from that it just defers to external commands, such as git.
You can run luarocks with the --verbose flag and it will output every external command it calls. You can then check what is the git command line it is calling, and try it directly from the command line. This should help to diagnose if any flag is causing problems.

As a workaround, you can force git to use https with the following command:
git config --global url.https://github.com/.insteadOf git://github.com/
Source: https://github.com/torch/rocks/issues/38

Related

Environment variables (zsh terminal) installed through npm on MacOS 12.4 Monterey - SOLVED

Background:
Dear Stackoverflow community. I recently switched from Windows to MacOS and am at a loss how to configure environment variables. Many of the previous questions asked here are about bash instead of zsh.
Goal:
I am trying to install an npm package globally. For instance:
npm install -g vercel
or any other package, and use it in my Visual Studio Code terminal (also zsh). If I want to deploy code I have to use 'npx vercel deploy' every time. I want to be able to use "vercel deploy" but instead I get:
zsh: command not found: vercel
What I tried so far:
Installing the package in zsh and visual studio code terminals (didn't work)
Setting the path equal on both VS and terminal: export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
I learned that you need to add environment variabels to a .zshrc file. I don't seem to have a zshrc file. When I do:
sudo ~/.zshrc
Password: XXXXXX
sudo: /Users/vincent/.zshrc: command not found
I am getting another error.
I read in the zsh man file that you should use $HOME/.zshrc instead. Again I am getting the same errors:
vincent#Vincents-MacBook-Air-2 ~ % $HOME/.zshrc
zsh: permission denied: /Users/vincent/.zshrc
vincent#Vincents-MacBook-Air-2 ~ % sudo $HOME/.zshrc
sudo: /Users/vincent/.zshrc: command not found
Update 1:
#slebetman Thank you for your explanation. When I open the terminal I go to home via "cd $HOME" which puts me in in the home directory. However there is no way for me to create a .zshrc file in that directory. Neither via touch or vs code. I am getting the following error: "Unable to write file '/home/.zshrc' (Unknown (FileSystemError): Error: ENOTSUP: operation not supported on socket, open '/home/.zshrc')"
Update 2:
I did manage to find the .zshrc file in visual studio code under /etc. I hope this will work. I was able to overwrite the file with Sudo and add environment variables to it.
Add this to the file .zshrc file under /etc and force overwrite it:
export vercel=/Users/vincent/.npm-global/bin/vercel
Screenshots below for those who will try in the future:
Image with .zshrc file layout
Final remarks:
I don't understand how it is so difficult to add environment variables on Mac while everything else is so easy.
I have read many different questions on stackoverflow, and I can't seem to solve it. Also since I am a newbie I am not allowed to comment on there so I post here in the hope that anyone can help me :)
Best,
Vincent
Note that when you do:
npx vercel deploy
Npm will execute vercel for you without installing it. It does that by temporarily downloading vercel. If you want to run vercel directly without using npx then simply don't use npx. Install it instead:
npm install -g vercel
The -g flag installs the module globally and if the module has a CLI it will be available globally as well (note that depending on your setup you may need admin/sudo privileges to use the -g flag). Now you can run vercel by simply typing:
vercel deploy
This works in all operating systems supported by node.js and npm. That means you can even do this in Windows. In fact I use npm to distribute my tools in a simple cross-platform way so I don't have to support multiple package managers like chocolatey (Windows), homebrew (Mac OS), deb (Debian based distros), rpm (Redhat based distros) etc. (npm does not require your software to be written in node.js - I have published packages on npm written in tcl and bash).

NPM not available when running installation script

I have an interesting issue, I have a setup or rails project and the deployment/upgrades works absolutely fine when running as a dedicated user (deploy) who is used to setup everything.
I am using codeDeploy to manage the deployments and it uses root user to do the deployment on AWS, but during the deployment it fails on running the same script because it's not able to find npm command
cd client && npm run build:client
sh: 1: npm: not found
rake aborted!
Command failed with status (127): [cd client && npm run build:client...]
If i run it manually to check that i also get nothing
root#ip-172-31-4-141:/home/ubuntu# su deploy -c "which npm"
root#ip-172-31-4-141:/home/ubuntu#
NPM is available via the deploy user but I am struggling to understand why it's not available via the root user
deploy#ip-172-31-4-141:/home/ubuntu$ which npm
/home/deploy/.nvm/versions/node/v7.8.0/bin/npm
Any help to get this resolved would be great.
Thanks,
The issue here was that AWS CodeDeploy when starts deployment loads only a minimum env; to load all the env variables I have exported the env and then in the deploy phase source that file, which resolves my issue

npm 3.10.10 install socket hang up error

I am using Node 6.10.1 and npm 3.10.10 on a Dell XPS 15 running Ubuntu 16.04 with Kernel 4.13.0.0-36-generic.
I am behind a corporate proxy which is configured through cntlm.
When I run an npm install -d on a project It works from a short time, and after a while I get Error: socket hang up.
I have found numerous questions about my problem but no solution seemed to work.
Here is an extract of a npm config list :
; cli configs
user-agent = "npm/3.10.10 node/v6.10.1 linux x64"
; userconfig /home/msb/.npmrc
https-proxy = "http://localhost:3128/"
registry = "http://urlTocorporateRegistryWhichWorksOnOtherComputers"
strict-ssl = false
; node bin location = /home/msb/.nvm/versions/node/v6.10.1/bin/node
; cwd = /home/msb
; HOME = /home/msb
; "npm config ls -l" to show all defaults.
I cannot change the registry since we are using some internal modules, and I have to keep the current versions of node/npm.
I have already tried :
Using the proxy directly in npm config rather than through cntlm
Limiting my upload/download capabilities with trickle through the command trickle -s -d 100 -u 100 npm install -d
Another indication : It works on Windows, and I have a collegue running Ubuntu 17.04 on a slower pc and it works for him. We think my machine might be a bit too brutal when requesting the registry. Does anyone know a way to slow npm requests ?
It used to work through yarn but some new developments have forced me to go back to npm.
Has anyone encountered and corrected this problem ?
Thanks for your help.
I experimented the same problem, with no apparent reason, on Ubuntu 18.04.
I finally used docker with bind mounts to solve it. The steps are the following:
Create a dockerfile with the following elements (you can also directly run with the used image if you don't need to configure a proxy like me)
FROM node:6.10.1
ENV HTTPS_PROXY "http://yourproxy:yourport/"
# Different RUN commands to configure npm and git corporate proxy
WORKDIR /home/root/
Build the image (from the dockerfile's folder): docker image build -f npm-installer/Dockerfile -t custom-npm-installer .
Go inside the project folder where you would normally run npm install
Run the following command to run the container interactively: docker container run -it --network host -v </host/path/to/pj>:/home/root/pj-to-install --name custom-npm-installer custom-npm-installer bash
You can now run the npm install command from the container. Careful however, you'll then need to use chmod on the node_modules folder recursively since the container uses root by default.
Another thing, if you're using node-sass, it is most of the time compiled on the fly when npm installing, and matches your OS current version/architecture. So if your linux distribution is not exactly the same than the container's you might need to recompile node-sass on your host after running npm install on the container. No worries though, node-sass will give you the command to run the moment you launch your application.

When i build the Telegram App it shows "SSignalKit/SSignalKit.h file not found"?

I cloned Telegram App but compilation fail with "SSignalKit/SSignalKit.h file not found"
What should i do to fix this?
You need to install the git submodules as well, this can be done with:
git submodule update --init --recursive
After successfully doing the that, build should fail because it cannot find the file config.h,
this can be fixed like described here.
Note: the submodules are linked with their ssh link, so if you don't have an authorized ssh for github on your mac, you either need to create one or change the links to the submodules repos from ssh links to https links (which can be found under [PROJECT_ROOT]/.gitmodules and [PROJECT_ROOT]/.git/config

Deploy to server with CircleCI and SCP

Say I have a repo that I'd like CircleCI to deploy after finishing the test sequence and the code is like so:
deployment:
staging:
branch: master
commands:
- scp -r wp-content/plugins/timespan username#servername.provider.host:public_html/wp-content/plugins
That works locally because I've set up the authentication that's necessary. But with CircleCI, that context isn't there and so it prompts for a password which I can't enter by having it on the next line, i.e. - passw0rd.
So I've tried a couple other things without success: 1) adding an ssh key into Circle and it rejects that by saying they don't support encrypted keys. 2) I tried using sshpass but wasn't able to add it as a dependency because of not knowing how nor which package manager to use to get it in.
Perhaps someone can enlighten me? I don't think this is too far off but am missing something.
You don't have to encrypt the SSH key.
I'm using CircleCi for the exact same thing, just add the uncrypted key to your SSH Permissions (you'll find it in your Project Settings on CircleCi in the "Permissions" section. Of course you will need the public key in your servers authorized_keys.
Otherwise you can add additional packages through your circle.yml: https://circleci.com/docs/installing-custom-software/
You can use your circle.yml file to run arbitrary commands against your build environment. You have root access to your environment via sudo, so you should be able to customize it to your heart’s content!
Example:
dependencies:
pre:
- sudo apt-get update; sudo apt-get install ssh-pass
I hope this will help you.
sshpass only needs to be installed on the client side. You do not need to install it on the server.
I am not familiar with CircleCI, but it sounds like you are trying to get it to install sshpass on the server, which is completely unnecessary. Just do sshpass -ppassw0rd scp ... in your CircleCI deployment script after having installed it on the server that runs CircleCI, and you should be fine.