Bug 2479711 - ipython does not include current working directory in sys.path
Summary: ipython does not include current working directory in sys.path
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: ipython
Version: 44
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Lumír Balhar
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2026-05-19 00:17 UTC by tlatorre9
Modified: 2026-06-27 01:10 UTC (History)
7 users (show)

Fixed In Version: ipython-9.14.1-2.fc45 ipython-9.14.1-2.fc44
Clone Of:
Environment:
Last Closed: 2026-06-18 11:31:15 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github ipython ipython issues 15214 0 None open CWD is not in sys.path when "-P" is used 2026-05-19 13:06:46 UTC

Description tlatorre9 2026-05-19 00:17:48 UTC
When running ipython from the command line, sys.path does not include the empty string for the current working directory:

$ ipython
In [1]: import sys

In [2]: sys.path
Out[2]: 
['/usr/lib64/python314.zip',
 '/usr/lib64/python3.14',
 '/usr/lib64/python3.14/lib-dynload',
 '/usr/local/lib64/python3.14/site-packages',
 '/usr/lib64/python3.14/site-packages',
 '/usr/lib/python3.14/site-packages']

This is different from the behavior in Fedora 40 and what I think is expected. For example, running the default python REPL:

$ python
>>> import sys
>>> sys.path
['', '/usr/lib64/python314.zip', '/usr/lib64/python3.14', '/usr/lib64/python3.14/lib-dynload', '/usr/local/lib64/python3.14/site-packages', '/usr/lib64/python3.14/site-packages', '/usr/lib/python3.14/site-packages']

Reproducible: Always

Steps to Reproduce:
1. Run ipython
2. import sys
3. print(sys.path)
Actual Results:
['/usr/lib64/python314.zip', '/usr/lib64/python3.14', '/usr/lib64/python3.14/lib-dynload', '/usr/local/lib64/python3.14/site-packages', '/usr/lib64/python3.14/site-packages', '/usr/lib/python3.14/site-packages']

Expected Results:
['', '/usr/lib64/python314.zip', '/usr/lib64/python3.14', '/usr/lib64/python3.14/lib-dynload', '/usr/local/lib64/python3.14/site-packages', '/usr/lib64/python3.14/site-packages', '/usr/lib/python3.14/site-packages']

Comment 1 Lumír Balhar 2026-05-19 12:46:50 UTC
Thank you for the report. I now see the root cause of this. We actually don't have to go that far, because it works as expected in Fedora 43 with ipython 8.37.0, but it does not work in Fedora 44 with ipython 9.9.0.

The different behavior is caused by: https://github.com/ipython/ipython/commit/bb8b2bab0f68088b15a4da0cd7ec6e6bfcafd6c9 (released first in 9.7.0), where ipython got the ability to respect sys.flags.safe_path/-P/PYTHONSAFEPATH and "-P" is exactly what we have in generated /usr/bin/ipython:

#! /usr/bin/python3 -P
import sys
from IPython import start_ipython
if __name__ == '__main__':
    if sys.argv[0].endswith('.exe'):
        sys.argv[0] = sys.argv[0][:-4]
    sys.exit(start_ipython())

I believe having the CWD in sys.path is the correct thing here, so we have to find a way to bring it back. But there is one problem. The "-P" is there since this change has been implemented in Fedora 37: https://fedoraproject.org/wiki/Changes/PythonSafePath, and when I remove it from the shebang above, it adds '' (empty string representing CWD, good) as well as '/usr/bin' (not so good, that's what the Fedora change wanted to avoid) into sys.path.

I'll discuss that with IPython developers and my colleagues, and we'll see.

Comment 2 Lumír Balhar 2026-05-19 13:06:47 UTC
Upstream report: https://github.com/ipython/ipython/issues/15214

Comment 3 Lumír Balhar 2026-06-14 10:24:03 UTC
I've created both upstream and downstream PRs. Could you please help me test it https://src.fedoraproject.org/rpms/ipython/pull-request/113 ?

Comment 4 tlatorre9 2026-06-15 20:43:51 UTC
Hi, how should I test the downstream PR? Is there an easy way to do that with dnf?

Comment 5 Lumír Balhar 2026-06-16 06:01:50 UTC
There is a rawhide scratch build as a part of the pull request: https://koji.fedoraproject.org/koji/taskinfo?taskID=146615143. And you can install the result via: dnf install https://kojipkgs.fedoraproject.org//work/tasks/5500/146615500/python3-ipython-9.14.1-2.fc45.noarch.rpm

But it's for rawhide. Can you test it for rawhide, or should I open a new PR for F44 so you can test it on your system?

Comment 6 tlatorre9 2026-06-17 20:48:49 UTC
I fired up a VM with Fedora rawhide and verified that the default ipython doesn't include the current working directory, but after removing it and installing your update via:

> dnf install https://kojipkgs.fedoraproject.org//work/tasks/5500/146615500/python3-ipython-9.14.1-2.fc45.noarch.rpm

it does correctly include the current workign directory.

Comment 7 Lumír Balhar 2026-06-18 10:39:32 UTC
Thank you. I'm going to release this fix on top of the latest upstream release also for F44 so feel free to test the update once available.

Comment 8 Fedora Update System 2026-06-18 11:28:06 UTC
FEDORA-2026-a3452cda6b (ipython-9.14.1-2.fc45) has been submitted as an update to Fedora 45.
https://bodhi.fedoraproject.org/updates/FEDORA-2026-a3452cda6b

Comment 9 Fedora Update System 2026-06-18 11:31:15 UTC
FEDORA-2026-a3452cda6b (ipython-9.14.1-2.fc45) has been pushed to the Fedora 45 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 10 Fedora Update System 2026-06-18 11:31:28 UTC
FEDORA-2026-8eacaf03b4 (ipython-9.14.1-2.fc44) has been submitted as an update to Fedora 44.
https://bodhi.fedoraproject.org/updates/FEDORA-2026-8eacaf03b4

Comment 11 Fedora Update System 2026-06-19 19:01:09 UTC
FEDORA-2026-8eacaf03b4 has been pushed to the Fedora 44 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2026-8eacaf03b4`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2026-8eacaf03b4

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 12 Fedora Update System 2026-06-27 01:10:44 UTC
FEDORA-2026-8eacaf03b4 (ipython-9.14.1-2.fc44) has been pushed to the Fedora 44 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.