Skip to content

Conversation

@JoeZiminski
Copy link
Member

@JoeZiminski JoeZiminski commented Sep 25, 2025

This PR fixes #71 but adding additional guards to the environment logging (#62). The issue in the stacktrace was that

conda_env = os.environ["CONDA_PREFIX"].split(os.sep)[-1]
conda_exe = os.environ["CONDA_EXE"]
conda_list = subprocess.run(
[conda_exe, "list", "--json"],
capture_output=True,
text=True)

threw a json.JSONDecodeError because the subprocess call failed with

conda_list = CompletedProcess(args=['/Users/k2366861/miniforge3/bin/conda', 'list', '--json'], returncode=1, stdout='', stderr='Traceback (most recent call last):\n  File "/Users/k2366861/miniforge3/bin/conda", line 12, in <module>\n    from conda.cli import main\nModuleNotFoundError: No module named \'conda\'\n')

Somehow the base conda cannot access the Python package conda that conda.cli seems to require. I'm not sure how this is possible or exactly what is going on here. But, rather than try and understand the many weird and wondering packaging errors I'm sure we'll encounter, I just extended the try/except clauses to fail gracefully if such an error is encountered. One thing this does not do is log these errors, so it will be difficult to troubleshoot when fancylog fails to get the environment packages. However, I think this is preferable to including these fancylog-related stacktraces in the logging output?

This requires no documentation, but I did not test as I'm not sure the exact environment set up which led to the error. Maybe the person who encountered the error can try fancylog from this branch?

@codecov
Copy link

codecov bot commented Sep 25, 2025

Codecov Report

❌ Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.11%. Comparing base (b2a1bcf) to head (e622e25).

Files with missing lines Patch % Lines
fancylog/fancylog.py 70.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #75      +/-   ##
==========================================
- Coverage   77.15%   76.11%   -1.04%     
==========================================
  Files           3        3              
  Lines         197      201       +4     
==========================================
+ Hits          152      153       +1     
- Misses         45       48       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JoeZiminski JoeZiminski changed the title Add additional guards to write_environment_packages. Add additional guards to write_environment_packages. Sep 25, 2025
@adamltyson
Copy link
Member

Thanks @JoeZiminski! TBC I couldn't replicate this, so far I've only seen it on @marcodallavecchia's system.

@marcodallavecchia if you get a chance to try this with brainreg, please do. Otherwise I suggest we just release it and keep an eye out for issues?

@adamltyson adamltyson merged commit d1df200 into main Sep 30, 2025
19 of 21 checks passed
@adamltyson adamltyson deleted the handle_conda_exe_error branch September 30, 2025 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Latest versions of fancylog cause a crash with brainreg

3 participants