morgangraphics / ansible-role-nvm

Installs NVM & Node.js on Debian/Ubuntu and RHEL/CentOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

You have $NVM_DIR set to \"/home/user/.nvm\", but that directory does not exist.

magick93 opened this issue · comments

Hello

When I run this role, using:

  - include_role: 
      name: ansible-role-nvm
    vars:
      nodejs_version: "4.8.0"

I get the following:

fatal: [127.0.0.1]: FAILED! => {"changed": true, "cmd": "wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | NVM_SOURCE= NVM_DIR=/home/user/.nvm PROFILE=.bashrc bash", "delta": "0:00:00.297033", "end": "2019-02-21 09:56:42.735199", "msg": "non-zero return code", "rc": 1, "start": "2019-02-21 09:56:42.438166", "stderr": "You have $NVM_DIR set to \"/home/user/.nvm\", but that directory does not exist. Check your profile files and environment.", "stderr_lines": ["You have $NVM_DIR set to \"/home/user/.nvm\", but that directory does not exist. Check your profile files and environment."], "stdout": "", "stdout_lines": []}

The error clearly states that the location where you are trying to install NVM doesn't exist. Does the user "user" home directory actually exist on the machine you are targeting? The role looks for the directory via an Ansible environment variable "{{ansible_env.HOME}}/.nvm" and attempts to install it there.

Run this command on your machine cut -d: -f1 /etc/passwd | sort

If userisn't in that list then that is the issue.

sys
...
systemd-timesync
usbmux
                <-- missing
uucp
uuidd
whoopsie
www-data

Let me know.

Yes, that user user does exist.

Thanks

Ok. Can you ensure that the user that is running the task is actually the "user" user?

You an add a command task to the playbook.

- name: Who AM I
  command: whoami

Does the user directory have the correct permissions?

755 rwxr-xr-x

What OS are you trying to provision on?

Yes, it is the user user who is running the playbook.

I am debugging, using:

- name: get the username running the deploy
  become: false
  local_action: command whoami
  register: username_on_the_host

- debug: var=username_on_the_host

which produces:

ok: [127.0.0.1] => {
    "username_on_the_host": {
        "changed": true, 
        "cmd": [
            "whoami"
        ], 
        "delta": "0:00:00.001775", 
        "end": "2019-02-21 15:49:09.958252", 
        "failed": false, 
        "rc": 0, 
        "start": "2019-02-21 15:49:09.956477", 
        "stderr": "", 
        "stderr_lines": [], 
        "stdout": "user", 
        "stdout_lines": [
            "user"
        ]
    }
}

I am able to proceed with using the ansible-role-nvm by preceding it wtih:

  - name: Creates directory
    file:
      path: /home/user/.nvm
      state: directory

What OS are you trying to provision on?

Ubuntu 18.10.

Ok, this has not been tested on Ubuntu 18.10 yet so I will have to look into it this weekend.

Glad you found a work around. In fact it's probably a good idea for the role to test if the .nvm directory exists before hand before trying to install. So, I will investigate the issue and update the role accordingly.

Addressed in PR#4