Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set private NPM registry for JupyterLab installs? #7827

Closed
prncevince opened this issue Jan 28, 2020 · 10 comments · Fixed by #8455
Closed

How to set private NPM registry for JupyterLab installs? #7827

prncevince opened this issue Jan 28, 2020 · 10 comments · Fixed by #8455
Labels
status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.

Comments

@prncevince
Copy link

prncevince commented Jan 28, 2020

Hi, a user here. Looked into #7109 but I still have no idea how to implement it ...
Can someone explain the steps that a user may take to set a private NPM registry for JupyterLab installs?

@fcollonval's any thoughts? It seems as though the default NPM registry gets put into the JupyterLab build. So I'm assuming that setting the registry must take place before building JupyterLab ... but I could be wrong.

I could not find simple instructions on exactly how to do this anywhere, so that's why I'm filing an issue.

@fcollonval
Copy link
Member

fcollonval commented Jan 28, 2020

@fcollonval's any thoughts? It seems as though the default NPM registry gets put into the JupyterLab build. So I'm assuming that setting the registry must take place before building JupyterLab ... but I could be wrong.

That is correct.

Can someone explain the steps that a user may take to set a private NPM registry for JupyterLab installs?

You need to set your private registry as yarn (jlpm) registry

yarn config set registry http://private.npm.repository --global

Then execute the jupyter lab commands to install extensions.

Note:

  • You can check that your configuration is correct by running
yarn config list

In the info yarn config section, your private registry should be listed as registry.

  • You can use jlpm instead of yarn.

@prncevince
Copy link
Author

prncevince commented Jan 28, 2020

Thanks for the answer. However, I believe this does not work, at least for JupyterLab 1.2.4.

Steps I took:
jlpm config set registry http://my.private.npm.repository --global
jupyter labextension install @jupyter-widgets/jupyterlab-manager

Didn't work, out. I also tried this:
jlpm config set registry http://my.private.npm.repository --global
jupyter lab build
jupyter labextension install @jupyter-widgets/jupyterlab-manager

I'm on a private network, so I hope that we can find an answer after I type all of this out. The log files after both of these installs are exactly the same.

Brief synopsis, JupyterLab is still using https://registry.npmjs.org as the registry.

Log file:

Yarn Configuration Loaded
Node v10.13.0
 
> H:\Anaconda3\npm.CMD pack @jupyter-widgets/jupyterlab-manager
npm ERR! code ENOTFOUND
npm ERR! erno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/@jupyter-widgets%2fjupyterlab-manager failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
 
... {condensing ... stuff about bad network connectively & setting the proxy config ... irrelevant}
 
Traceback (most recent call last):
 
    File "H:\Anaconda3\lib\site-packages\jupyterlab\debuglog.py", line 47, in debug_logging
        yield
 
    File "H:\Anaconda3\lib\site-packages\jupyterlab\labextensions.py", line 93, in start
        ans = self.run_task()
 
    File "H:\Anaconda3\lib\site-packages\jupyterlab\labextensions.py", line 149, in run_task
        for i, arg in enumerate(self.extra_args)
 
    File "H:\Anaconda3\lib\site-packages\jupyterlab\labextensions.py", line 149, in <listcomp>
        for i, arg in enumerate(self.extra_args)
 
    File "H:\Anaconda3\lib\site-packages\jupyterlab\commands.py", line 398, in install_extension
        return handler.Install_extension(extension, pin=pin)
 
    File "H:\Anaconda3\lib\site-packages\jupyterlab\commands.py", line 611, in install_extension
        info = self._install_extension(extension, tempdir, pin=pin)
 
    File "H:\Anaconda3\lib\site-packages\jupyterlab\commands.py", line 1501, in _install_extension
        info = self._extract_package(extension, tempdir, pin=pin)
 
    File "H:\Anaconda3\lib\site-packages\jupyterlab\commands.py", line 1571, in _extract_package
        raise ValueError (msg % source)

Also, the output to jlpm config list shows that my registry is set to http://my.private.npm.repository/ (both from the NPM config & the yarn config)

@prncevince
Copy link
Author

prncevince commented Jan 30, 2020

@fcollonval thoughts on what can be tried next? I also tried the
sequence of commands:

jlpm config set registry http://my.private.npm.repository --global
jupyter lab clean 
jupyter lab build 
jupyter labextension install @jupyter-widgets/jupyterlab-manager

And I receive the exact same error results. It’s still trying to connect to the https://registry.npmjs.org.

Also to note, I'm on Windows right, jlpm ends up storing and reading the global registry info to C:\Users\username\.yarnrc. There's also a .yarnrc stored in $PREFIX/share/jupyter/lab/staging. However, this doesn't get updated after running jlpm config set registry http://my.private.npm.repository --global. So I decided to try and add the registry to this .yarnrc too, still no luck. My Anaconda is stored on my H:\ network drive, so I decided to store a copy of the .yarnrc next to my .npmrc in ~/.yarnc, still no luck.

Also to note, jupyter lab clean doesn't remove the static directory in $PREFIX/share/jupyter/lab (as jupyter lab clean -h documents). It only removes staging (I checked this). However, jupyter lab build does appear to rewrite files in this directory.

So, all in all, it appears that setting the registry via jlpm does NOT work, and that #7109 is not a fix, so this is still a bug. Unless I'm missing something...

There is a "complete log" given as output into another file. I can type all of this out if it's going to be helpful, but I need some correspondence...
Really it just tells me that JupyterLab is trying to reach registry.npmjs.org, which I don't have access to b/c I'm on a private network, so obviously it's going to fail.

One command that the file shows is probably the full command that JupyterLab is running behind the scenes:
"H:\\Anaconda3\\node.exe" "H:\\Anaconda3\\node_modules\\npm\\bin\\npm-cli.js" "pack" "@jupyter-widgets/jupyterlab-manager"

So maybe this is an issue with node npm-cli.js?

@RedTn
Copy link
Member

RedTn commented Apr 15, 2020

@fcollonval's any thoughts? It seems as though the default NPM registry gets put into the JupyterLab build. So I'm assuming that setting the registry must take place before building JupyterLab ... but I could be wrong.

That is correct.

Can someone explain the steps that a user may take to set a private NPM registry for JupyterLab installs?

You need to set your private registry as yarn (jlpm) registry

yarn config set registry http://private.npm.repository --global

Then execute the jupyter lab commands to install extensions.

Note:

  • You can check that your configuration is correct by running
yarn config list

In the info yarn config section, your private registry should be listed as registry.

  • You can use jlpm instead of yarn.

@fcollonval
is there anyway to do this at the workspace level rather than on a global level with yarn? like with a .yarnrc?

@prncevince
Copy link
Author

prncevince commented Apr 15, 2020

FYI, I ended up figuring out how to make this work on my Windows 10 platform setup.

A global yarnrc (NOT the dot-profile .yarnc) was read from the %USERPROFILE% directory, so full path %USERPROFILE%\yarnrc. In addition, for updates to plugins to be made, the global npmrc needed to be set AS WELL (same registry value as http://private.npm.repository of course).

This is strange behavior b/c it's not really mentioned in the docs for the default global path to be read from %USERPROFILE%, but hey nothing's straight forward on Windows.

@jeffreys-cat
Copy link

jeffreys-cat commented May 14, 2020

Has anyone found a way to set a private npm registry in Linux?

@nscozzaro
Copy link
Contributor

nscozzaro commented May 20, 2020

I also could benefit from some clarity around the correct approach to set a private NPM registry for JupyterLab. We want to allow users to install extensions from the private repo since our network has a firewall that blocks access to the public NPM repo.

I noticed in this comment #7109 (comment) that editing jupyter_config.json might be one method, is that right? Is there documentation discussing this further?

  "LabApp":{
    "yarn_registry": "https://artifactory.server:8080/artifactory/api/npm/npm-all/"
  },
  "BaseExtensionApp":{
    "yarn_registry": "https://artifactory.server:8080/artifactory/api/npm/npm-all/"
  },
  "LabBuildApp":{
    "yarn_registry": "https://artifactory.server:8080/artifactory/api/npm/npm-all/"
  }
}

@fcollonval
Copy link
Member

fcollonval commented May 21, 2020

Hey guys,

I updated the documentation in the hope to clarify this use case:


Usage with private NPM registry

To install extensions, you will need access to a NPM packages registry. Some companies do not allow
reaching directly public registry and have a private registry. To use it, you need to configure npm
and yarn to point to that registry (ask your corporate IT department for the correct URL):

    npm config set registry https://registry.company.com/
    yarn config set registry https://registry.company.com/

JupyterLab will pick up that registry automatically.

You can check which registry URL is used by JupyterLab by running:
python -c "from jupyterlab.commands import AppOptions; print(AppOptions().registry)"

@emelens
Copy link

emelens commented May 21, 2020

I have to use yarn behind firewall via artifactory. I tried setting artifactory url.
However, I am getting SSL errors

Error: self signed certificate in certificate chain
at TLSSocket.onConnectSecure (_tls_wrap.js:1321:34)
at TLSSocket.emit (events.js:223:5)
at TLSSocket._finishInit (_tls_wrap.js:794:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:608:12)

I ran yarn config set strict-ssl false . Yarn was able to run fine after that.
And my jupyter labextension install completed successfully.

I ran jupyter labextension list to see the list of extensions. I see the extensions I installed in the output.

@fcollonval
Copy link
Member

fcollonval commented May 21, 2020

@emelens thanks for reporting your experience.

Certificate validation (i.e. SSL stuff) is unspecific to JupyterLab. If you get such an error, this means your computer is not aware of certificates emitted by your company for some servers. I strongly advice contacting your IT department to fix the deployment of the certificates to your computer rather than using strict-ssl=false as configuration as it is unsafe.

@lock lock bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Jun 24, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants