Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Julia language: skip startup.jl file#3496

Merged
asottile merged 1 commit intopre-commit:mainfrom
ericphanson:eph/jl-startup
Aug 2, 2025
Merged

Julia language: skip startup.jl file#3496
asottile merged 1 commit intopre-commit:mainfrom
ericphanson:eph/jl-startup

Conversation

@ericphanson
Copy link
Contributor

Adds--startup-file=no to both invocations of Julia (install & run). The startup file is a Julia script that users can configure to run commands before the start of their Julia session. It is typically used to load developer packages like Revise and not used "in-production". Here when we run our pre-commit hooks we do not want to run the user's startup file which could have dependencies the current environment does not have.

Split out from#3494

The first commit fails locally for me, showing that the test is effective:

pytesttests-sktest_julia_hook_with_startup===========================================testsessionstarts===========================================platformdarwin--Python3.13.4,pytest-8.4.1,pluggy-1.6.0rootdir:/Users/eph/pre-commitconfigfile:tox.iniplugins:env-1.1.5collected802items/801deselected/1selectedtests/languages/julia_test.pyF================================================FAILURES=================================================______________________________________test_julia_hook_with_startup_______________________________________tmp_path=PosixPath('/private/var/folders/jb/plyyfc_d2bz195_0rc0n_zcw0000gp/T/pytest-of-eph/pytest-21/test_julia_hook_with_startup0')deftest_julia_hook_with_startup(tmp_path):# We will temporarily use a new Julia depot so we can freely write a# startup.jl fileexisting_depot=os.getenv('JULIA_DEPOT_PATH')try:withtempfile.TemporaryDirectory()asdepot_tempdir:os.environ['JULIA_DEPOT_PATH']=depot_tempdirdepot_path=Path(depot_tempdir)depot_path.joinpath('config').mkdir(exist_ok=True)startup=depot_path.joinpath('config','startup.jl')# write a startup.jl file that throws an error so# we know it's not usedstartup.write_text('error("Startup file used!")\n')# check that the test still succeeds even with a bad startup file>test_julia_hook(tmp_path)tests/languages/julia_test.py:49: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _tests/languages/julia_test.py:32:intest_julia_hookassertrun_language(tmp_path,julia,'src/main.jl')==expected^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^testing/language_helpers.py:26:inrun_languagelanguage.install_environment(prefix,version,deps)pre_commit/languages/julia.py:129:ininstall_environmentcmd_output_b(__ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _check=Truecmd= ('/Users/eph/.juliaup/bin/julia','-e','\n        @assert length(ARGS) > 0\n        hook_env = ARGS[1]\n        deps ...ar/folders/jb/plyyfc_d2bz195_0rc0n_zcw0000gp/T/pytest-of-eph/pytest-21/test_julia_hook_with_startup0/juliaenv-default')kwargs= {'cwd':'/private/var/folders/jb/plyyfc_d2bz195_0rc0n_zcw0000gp/T/pytest-of-eph/pytest-21/test_julia_hook_with_startup0','stderr':-1,'stdin':-1,'stdout':-1}proc=<Popen:returncode:1args: ('/Users/eph/.juliaup/bin/julia','-e','\n     ...>, stdout_b = b''stderr_b = b'ERROR:LoadError:Startupfileused!\nStacktrace:\n [1]error(s::String)\n   @Base ./error.jl:35\n [2]top-levelsc...tup.jl:1\ninexpressionstartingat/var/folders/jb/plyyfc_d2bz195_0rc0n_zcw0000gp/T/tmplwwx2crp/config/startup.jl:1\n'returncode=1defcmd_output_b(*cmd:str,check:bool=True,**kwargs:Any,    )->tuple[int,bytes,bytes|None]:_setdefault_kwargs(kwargs)try:cmd=parse_shebang.normalize_cmd(cmd,env=kwargs.get('env'))exceptparse_shebang.ExecutableNotFoundErrorase:returncode,stdout_b,stderr_b=e.to_output()else:try:proc=subprocess.Popen(cmd,**kwargs)exceptOSErrorase:returncode,stdout_b,stderr_b=_oserror_to_output(e)else:stdout_b,stderr_b=proc.communicate()returncode=proc.returncodeifcheckandreturncode:>raiseCalledProcessError(returncode,cmd,stdout_b,stderr_b)Epre_commit.util.CalledProcessError:command: ('/Users/eph/.juliaup/bin/julia','-e','\n        @assert length(ARGS) > 0\n        hook_env = ARGS[1]\n        deps = join(ARGS[2:end], " ")\n\n        # We prepend @stdlib here so that we can load the package manager even\n        # though `get_env_patch` limits `JULIA_LOAD_PATH` to just the hook env.\n        pushfirst!(LOAD_PATH, "@stdlib")\n        using Pkg\n        popfirst!(LOAD_PATH)\n\n        # Instantiate the environment shipped with the hook repo. If we have\n        # additional dependencies we disable precompilation in this step to\n        # avoid double work.\n        precompile = isempty(deps) ? "1" : "0"\n        withenv("JULIA_PKG_PRECOMPILE_AUTO" => precompile) do\n            Pkg.instantiate()\n        end\n\n        # Add additional dependencies (with precompilation)\n        if !isempty(deps)\n            withenv("JULIA_PKG_PRECOMPILE_AUTO" => "1") do\n                Pkg.REPLMode.pkgstr("add " * deps)\n            end\n        end\n        ','--','/private/var/folders/jb/plyyfc_d2bz195_0rc0n_zcw0000gp/T/pytest-of-eph/pytest-21/test_julia_hook_with_startup0/juliaenv-default')Ereturncode:1Estdout: (none)Estderr:EERROR:LoadError:Startupfileused!EStacktrace:E                [1]error(s::String)E                  @Base ./error.jl:35E                [2]top-levelscopeE                  @/var/folders/jb/plyyfc_d2bz195_0rc0n_zcw0000gp/T/tmplwwx2crp/config/startup.jl:1Einexpressionstartingat/var/folders/jb/plyyfc_d2bz195_0rc0n_zcw0000gp/T/tmplwwx2crp/config/startup.jl:1pre_commit/util.py:111:CalledProcessError=========================================shorttestsummaryinfo=========================================FAILEDtests/languages/julia_test.py::test_julia_hook_with_startup-pre_commit.util.CalledProcessError:command: ('/Users/eph/.juliaup/bin/julia','-e','\n        @asser...====================================1failed,801deselectedin1.30s====================================

The second commit is the implementation change which shows that the the fix is effective:

pytesttests-sktest_julia_hook_with_startup===========================================testsessionstarts===========================================platformdarwin--Python3.13.4,pytest-8.4.1,pluggy-1.6.0rootdir:/Users/eph/pre-commitconfigfile:tox.iniplugins:env-1.1.5collected802items/801deselected/1selectedtests/languages/julia_test.py .==============================1passed,801deselectedin64.48s (0:01:04)===============================

abelsiqueira reacted with thumbs up emoji
Copy link
Member

@asottileasottile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

ddellspe reacted with eyes emoji
@asottileasottile merged commita5fe6c5 intopre-commit:mainAug 2, 2025
28 checks passed
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull requestAug 12, 2025
This MR contains the following updates:| Package | Update | Change ||---|---|---|| [pre-commit](https://github.com/pre-commit/pre-commit) | minor | `4.2.0` -> `4.3.0` |MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).**Proposed changes to behavior should be submitted there as MRs.**---### Release Notes<details><summary>pre-commit/pre-commit (pre-commit)</summary>### [`v4.3.0`](https://github.com/pre-commit/pre-commit/blob/HEAD/CHANGELOG.md#430---2025-08-09)[Compare Source](pre-commit/pre-commit@v4.2.0...v4.3.0)\==================##### Features- `language: docker` / `language: docker_image`: detect rootless docker.  - [#&#8203;3446](pre-commit/pre-commit#3446) MR by [@&#8203;matthewhughes934](https://github.com/matthewhughes934).  - [#&#8203;1243](pre-commit/pre-commit#1243) issue by [@&#8203;dkolepp](https://github.com/dkolepp).- `language: julia`: avoid `startup.jl` when executing hooks.  - [#&#8203;3496](pre-commit/pre-commit#3496) MR by [@&#8203;ericphanson](https://github.com/ericphanson).- `language: dart`: support latest dart versions which require a higher sdk  lower bound.  - [#&#8203;3507](pre-commit/pre-commit#3507) MR by [@&#8203;bc-lee](https://github.com/bc-lee).</details>---### Configuration📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.🔕 **Ignore**: Close this MR and you won't be reminded about this update again.--- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box---This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS41OC4yIiwidXBkYXRlZEluVmVyIjoiNDEuNTguMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@asottileasottileasottile approved these changes

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@ericphanson@asottile

[8]ページ先頭

©2009-2026 Movatter.jp