Git Product home page Git Product logo

Comments (10)

jazzdan avatar jazzdan commented on May 18, 2024 1

I hear ya. :) I will try to reproduce this on Linux later and, if that doesn't work, I will disable my System Integrity Protection and see what I can find.

from dotslash.

bolinfest avatar bolinfest commented on May 18, 2024

Out of curiosity, how are you getting/building DotSlash itself?

I just filed #23 and I'm curious if it could be related.

from dotslash.

jazzdan avatar jazzdan commented on May 18, 2024

Hey @bolinfest. I'm definitely not using homebrew in this case. I think I downloaded it directly from the most recent release. I just ensured that I am using the macOS binary listed there and it still fails in the same way:

$ file ~/Downloads/dotslash
/Users/dan/Downloads/dotslash: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64]
/Users/dan/Downloads/dotslash (for architecture x86_64):	Mach-O 64-bit executable x86_64
/Users/dan/Downloads/dotslash (for architecture arm64):	Mach-O 64-bit executable arm64
$ /Users/dan/Downloads/dotslash scripts/bin/python
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'scripts/bin/python'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/install/lib/python3.11'
  sys._base_executable = '/Users/dan/devel/backend2/scripts/bin/python'
  sys.base_prefix = '/install'
  sys.base_exec_prefix = '/install'
  sys.platlibdir = 'lib'
  sys.executable = '/Users/dan/devel/backend2/scripts/bin/python'
  sys.prefix = '/install'
  sys.exec_prefix = '/install'
  sys.path = [
    '/install/lib/python311.zip',
    '/install/lib/python3.11',
    '/install/lib/python3.11/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000001f235bac0 (most recent call first):
  <no Python frame>

FWIW it also still fails with the first release of dotslash:

$ /Users/dan/Downloads/dotslash_old scripts/bin/python
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'scripts/bin/python'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/install/lib/python3.11'
  sys._base_executable = '/Users/dan/devel/backend2/scripts/bin/python'
  sys.base_prefix = '/install'
  sys.base_exec_prefix = '/install'
  sys.platlibdir = 'lib'
  sys.executable = '/Users/dan/devel/backend2/scripts/bin/python'
  sys.prefix = '/install'
  sys.exec_prefix = '/install'
  sys.path = [
    '/install/lib/python311.zip',
    '/install/lib/python3.11',
    '/install/lib/python3.11/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000001f235bac0 (most recent call first):
  <no Python frame>

from dotslash.

bolinfest avatar bolinfest commented on May 18, 2024

@jazzdan Hmm, while we do rewrite arg0 on both Mac and Linux:

dotslash/src/execution.rs

Lines 110 to 111 in 92fe071

#[cfg(unix)]
std::os::unix::process::CommandExt::arg0(&mut command, file_arg);

I wonder if Python is looking for some resource relative to the executable and we're not convincing it sufficiently?

Also, do you still get this error if you try to use it to run a Python file? Or is it just the REPL case?

from dotslash.

bolinfest avatar bolinfest commented on May 18, 2024

In particular, I'm curious how it is producing that /install path that it seems to be looking through.

from dotslash.

jazzdan avatar jazzdan commented on May 18, 2024

@bolinfest good question! So --version works just fine for example:

./scripts/bin/python --version
Python 3.11.8

But ./scripts/bin/python helloworld.py does not:

$ echo "print('hello world')" > helloworld.py
$ ./scripts/bin/python helloworld.py
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = './scripts/bin/python'
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = '/install/lib/python3.11'
  sys._base_executable = '/Users/dan/devel/backend2/scripts/bin/python'
  sys.base_prefix = '/install'
  sys.base_exec_prefix = '/install'
  sys.platlibdir = 'lib'
  sys.executable = '/Users/dan/devel/backend2/scripts/bin/python'
  sys.prefix = '/install'
  sys.exec_prefix = '/install'
  sys.path = [
    '/install/lib/python311.zip',
    '/install/lib/python3.11',
    '/install/lib/python3.11/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000001f235bac0 (most recent call first):
  <no Python frame>

And again, running python from the dotslash cache works fine

$ /Users/dan/Library/Caches/dotslash/70/8af721089c037927052d4af721f1618603ad29/python/install/bin/python helloworld.py
hello world

The file type looks correct for my system (darwin arm64) so I think my dotslash file is set up correctly:

file /Users/dan/Library/Caches/dotslash/70/8af721089c037927052d4af721f1618603ad29/python/install/bin/python
/Users/dan/Library/Caches/dotslash/70/8af721089c037927052d4af721f1618603ad29/python/install/bin/python: Mach-O 64-bit executable arm64

Thanks for taking a look!

from dotslash.

bolinfest avatar bolinfest commented on May 18, 2024

If this were Linux, I would say we could use strace as a first pass to see what sorts of syscalls/file opens DotSlash/Python are trying to do. Unfortunately [IMO], macOS seems to get more and more locked down such that these sorts of observability tools are extremely difficult to get set up to run :(

from dotslash.

jazzdan avatar jazzdan commented on May 18, 2024

This also reproduces on Linux. Here's an strace of executing the dotslash file, and it failing:

https://gist.github.com/jazzdan/f4dd9eb4231a9fd983f85b5056e498b3

Here is an strace of executing the file in the dotslash cache directly, and it succeeding:

https://gist.github.com/jazzdan/71dbd744d680bd14f7e26a434d36fad2

from dotslash.

jazzdan avatar jazzdan commented on May 18, 2024

It looks like I might be running in to this issue here indygreg/python-build-standalone#57 (comment)

the default search path compiled into the binary reflects the build environment instead of the run-time layout.

But I'll admit to being a bit over my head here!

from dotslash.

jazzdan avatar jazzdan commented on May 18, 2024

In this case running the dotslash file like this seems to fix it:

PYTHONHOME=/home/ubuntu/.cache/dotslash/9c/14429f2885b29b37cd1df0c879aff1862b418a/python/install ./python

from dotslash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.