0

I'm trying to add some custom Javascript to a Jupyter notebook by using the custom.js they provide. On their webpage, they say you can find the custom.js folder at ~/.jupyter/custom/custom.js.

However, when I look for the file there, I can't see it. I don't even have a custom directory. Instead, I see a file called migrated.

Weirdly, if I run Jupyter and go http://localhost:8888/custom/custom.js I can see the file, but it's not present in the folder.

What's happening here? Should I just create my own custom folder?

Connor
  • 867
  • 7
  • 18
  • You don't say what sort of system you are working on. The part represented by the tilde may be different. Also, the part represented by `.jupyter` means that directory is hidden. Are you accounting for that. It would seem you have that file if that `http://localhost:8888/custom/custom.js` works and you are running the typical things locally. I would not advise creating a folder at this time since that link works. I wonder if running [this code](https://stackoverflow.com/a/39921293/8508004) in your notebook may help. – Wayne Jan 11 '23 at 16:11
  • @Wayne I added the folder and file, and it seems to have worked. I've tried exploring this on three machines, two windows one mac, all with fresh Jupyter installs, and I get the same issue. After adding the folder and files I did run that code, it showed me what I pasted in there. Do you use use Jupyter? Have you come across an issue like this before? – Connor Jan 11 '23 at 16:16
  • 1
    Glad to hear it works. I was trying to play it more cautious just to avoid creating issues. I wonder if the documentation is actually worded poorly? It's stated differently [here](https://stackoverflow.com/a/36032376/8508004) by someone who works on Jupyter. The 'should 'could be interpreted as you can make one yourself. (The first sentence [here](https://github.com/jupyter/notebook/issues/5069) is consistent with that expectation, too.) The language on the documentation your point out makes it like it should be there. I more often use Jupyter on JupyterHub, which is a bit different. – Wayne Jan 11 '23 at 16:34
  • 1
    @Wayne, yes, it's extremely vague. Seems like a pretty huge oversight, but maybe this feature isn't used that often. Still, at least I have an answer! Hopefully my answer below is helpful for anyone else in the same situation. Thank you for your input! – Connor Jan 11 '23 at 16:40

1 Answers1

0

This worked for me.

Open a terminal and visit the path given in the documentation. Run:

> ls -a

To get a list of everything in the directory, the -a option includes hidden files. If the directory definitely isn't there, run the following commands:

> mkdir custom
> cd custom
> touch custom.js

In order, the first command creates the custom directory, the second command moves you into that directory, and the third creates the custom.js file within that directory.

To edit custom.js in your code editor of choice run:

> open custom.js

To edit custom.js directly in your terminal, run:

> vim custom.js

Hopefully, that solves the issue for everyone.

Connor
  • 867
  • 7
  • 18