Always use LF instead of CRLF for *.ipynb files regardless of platform and when sending code to the kernel
See original GitHub issueEnvironment data
- VS Code version: 1.53.0-insider (2021-01-29T05:13:48.533Z)
- Jupyter Extension version (available under the Extensions sidebar): v2020.12.414227025
- Python Extension version (available under the Extensions sidebar): 2021.2.518958983-dev
- OS (Windows | Mac | Linux distro) and version: Windows 10
- Python and/or Anaconda version: Python 3.8.5 using Anaconda
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
- Jupyter server running: Local
Expected behaviour
When editing a notebook, lines ending in “\n” shouldn’t be modified to “\r\n”
Actual behaviour
It appears as soon as I modify the content of a cell, the editor is replacing all “\n” by “\r\n”. I don’t understand why, and it’s causing downstream tools (e.g. nbdev/nbparse) to no longer be able to parse the .ipynb properly.
Steps to reproduce:
This seems to happen for any .ipynb file on my PC. I did a git clone of nbdev (https://github.com/fastai/nbdev/blob/master/nbs/00_export.ipynb
) and ran the notebook, but chances are you only need to open a file:
- download https://github.com/fastai/nbdev/blob/master/nbs/00_export.ipynb
- open the file in vscode
- modify a cell
- do a diff on the cell.
- notice that the newlines are messed up.
Logs
Output for Jupyter
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Jupyter
)
User belongs to experiment group 'pythonJoinMailingListVar1'
User belongs to experiment group 'jupyterTest'
User belongs to experiment group 'NativeNotebookEditor'
> D:\Users\claforte\Anaconda3\envs\fastai\python.exe c:\Users\claforte\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py -c "import jupyter"
> D:\Users\claforte\Anaconda3\envs\fastai\python.exe c:\Users\claforte\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py -c "import notebook"
> D:\Users\claforte\Anaconda3\envs\fastai\python.exe c:\Users\claforte\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py jupyter kernelspec --version
> D:\Users\claforte\Anaconda3\envs\fastai\python.exe c:\Users\claforte\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v
> D:\Users\claforte\Anaconda3\envs\fastai\python.exe c:\Users\claforte\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v
> D:\Users\claforte\Anaconda3\envs\fastai\python.exe c:\Users\claforte\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.jupyter_daemon -v
> D:\Users\claforte\Anaconda3\envs\tensorflow\python.exe c:\Users\claforte\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py -c "import ipykernel"
> D:\Users\claforte\Anaconda3\envs\fastai\python.exe c:\Users\claforte\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py -c "import ipykernel"
> D:\Users\claforte\Anaconda3\envs\fastai\python.exe c:\Users\claforte\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.kernel_launcher_daemon -v
Started kernel Python 3
> D:\Users\claforte\Anaconda3\envs\fastai\python.exe c:\Users\claforte\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.kernel_launcher_daemon -v
> D:\Users\claforte\Anaconda3\envs\fastai\python.exe c:\Users\claforte\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.kernel_launcher_daemon -v
> D:\Users\claforte\Anaconda3\envs\fastai\python.exe c:\Users\claforte\.vscode-insiders\extensions\ms-toolsai.jupyter-2020.12.414227025\pythonFiles\pyvsc-run-isolated.py vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.kernel_launcher_daemon -v
XXX
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:28 (13 by maintainers)
Top Results From Across the Web
CRLF vs. LF: Normalizing Line Endings in Git
A better solution is to add a .gitattributes file to your repo so you can enforce line endings consistently in your codebase regardless...
Read more >LF will be replaced by CRLF in git - What is that and is it ...
The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in <filename>. What's the...
Read more >How to Ensure Always LF not CRLF on Windows
I am using PhpStorm 2016.2.2 on Windows 10 and want to only ever have Unix ... Warning: LF will be replaced by CRLF...
Read more >Messaging in Jupyter — jupyter_client 7.4.8 documentation
This document explains the basic communications design and messaging specification for how Jupyter frontends and kernels communicate. The ZeroMQ library ...
Read more >How to Version Control Jupyter Notebooks - Nextjournal
Jupyter notebooks generate files that may contain metadata, source code, formatted text, ... Jupyter notebook files are human-readable JSON .ipynb files.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is honestly very annoying behavior (I mean conversion of LF to CRLF). After such a notebook uploaded to Jupyter Lab server, I start to have incorrect character typed. This is another bug of Jupyter Lab, which unfortunately destroy your DEV experience. See here: https://github.com/jupyterlab/jupyterlab/issues/2951 (bug reproduced in latest Jupyter Lab) So basically after editing of a notebook in VSCode you have destroyed notebook in any external server!
Users can configure the
files.eol
setting as a temporary workaround, and we can consider fixing this in the builtin ipynb extension. Note also that Colab always uses LF (they just fixed this behavior) https://github.com/jupyterlab/jupyterlab/issues/9465#issuecomment-802215114 /cc @roblourens @DonJayamanne