jupyterlab / jupyterlab-google-drive

Cloud storage for JupyterLab using Google Drive
BSD 3-Clause "New" or "Revised" License
400 stars 76 forks source link

cannot active plugin in jupyterlab 0.24.1 #19

Closed ktong closed 7 years ago

ktong commented 7 years ago

index.js:268 Error: No provider for: jupyter.services.commandpalette. at JupyterLab.Application.resolveRequiredService (/lab/main.bundle.js:185355:35) at /lab/main.bundle.js:185313:70 at Array.map (native) at JupyterLab.Application.activatePlugin (/lab/main.bundle.js:185313:38) at /lab/main.bundle.js:185439:26 at Array.map (native) at JupyterLab.Application.start (/lab/main.bundle.js:185438:33) at main (/lab/main.bundle.js:130911:9)

ian-r-rose commented 7 years ago

This type of error usually occurs when you have a version-incompatible plugin. Can you verify that you are running @jupyterlab/google-drive v0.2.0?

ktong commented 7 years ago

it's 0.2.0. 0.1.1 cannot be installed due to imcompatible plugin

Enabling: jupyterlab
- Writing config: /srv/venv/etc/jupyter
    - Validating...
      jupyterlab  OK
> npm pack @jupyterlab/google-drive
> npm install /srv/venv/share/jupyter/lab/extensions/jupyterlab-google-drive-0.2.0.tgz
> npm install
> npm run build
ian-r-rose commented 7 years ago

Hmm, puzzling. It seems that there are probably still some old assets somewhere that are getting in the way. I just saw this error in an environment, and was able to fix it by running jupyter lab clean && jupyter lab build.

ktong commented 7 years ago

My env should be clean because it's built by docker. Will double check it later.

ian-r-rose commented 7 years ago

This is a tough one, though now I can reproduce your problem! If I create a new conda environment and install jupyterlab into it

conda create -n test -c conda-forge python=3 jupyterlab nodejs
source activate test
jupyter labextension install @jupyterlab/google-drive
jupyter lab

I see the same error as you. If I subsequently run

jupyter lab clean
jupyter lab build

it works as expected. I am not sure what is causing the error yet, but we are making progress!

ktong commented 7 years ago

thanks. Will add jupyter lab clean & build in docker as temporary workaround

ian-r-rose commented 7 years ago

Good catch, @ktong. It appears to have been a bug in the extension build system, and fixed in jupyterlab/jupyterlab#2483.

ktong commented 7 years ago

cool. thanks

ktong commented 7 years ago

It's solved in 0.25

ian-r-rose commented 7 years ago

:+1:

nscozzaro commented 5 years ago

@ian-r-rose I'm getting a similar error :

index.js:268 Error: No provider for: @jupyterlab/apputils:ICommandPalette.
    at JupyterLab.push.2R+v.Application.resolveRequiredService (index.js:182)
    at index.js:140
    at Array.map (<anonymous>)
    at JupyterLab.push.2R+v.Application.activatePlugin (index.js:140)
    at index.js:266
    at Array.map (<anonymous>)
    at JupyterLab.push.2R+v.Application.start (index.js:265)
    at main (index.out.js:1518)

and I'm trying to figure out what could be causing it. However, it's a different situation: I'm building a custom JupyterLab extension, and started out by following the Astronomy Picture tutorial. I'm trying to use Webpack to create the bundle of the extension (not part of the tutorial). In the extension there's an import import {ICommandPalette, MainAreaWidget, WidgetTracker} from '@jupyterlab/apputils';, so from reading these Github issues threads could it be the case that the bundle is including a copy of ICommandPalette which then conflicts with JupyterLab's ICommandPalette? Please let me know if you have any suggestions.

nscozzaro commented 5 years ago

I ended up resolving this by using the webpack-node-externals package:

var nodeExternals = require('webpack-node-externals');
const VueLoaderPlugin = require('vue-loader/lib/plugin');

module.exports = {
    entry: [
        './src/plugin.js'
    ],
    target: 'node', // in order to ignore built-in modules like path, fs, etc.
    externals: [nodeExternals()],
    output: {
        path: path.resolve(__dirname, 'lib'),
        filename: 'plugin.js',
        libraryTarget: 'commonjs-module'
    },
ian-r-rose commented 5 years ago

I confess I don't quite understand the shape of the solution, but thanks for following up @nscozzaro so that others may try it if they run into something similar.

nscozzaro commented 5 years ago

@ian-r-rose By default, Webpack includes all the code of dependencies in the bundle. However, you can tell it not to by specifying externals: in the webpack config. The generated bundle then relies on the external packages and you have to tell it where to find them. So I had import {ICommandPalette, MainAreaWidget, WidgetTracker} from '@jupyterlab/apputils';, and webpack-node-externals tells webpack where to find '@jupyterlab/apputils', namely in the node_modules folder: externals: [nodeExternals()]. The problem was as I had suspected: the bundle was including a copy of the dependencies, leading to the error, so removing them from the bundle was the solution.