Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import behaves differently for the first run than the subsequent runs #483

Closed
typeless opened this issue Jul 21, 2023 · 4 comments
Closed

Comments

@typeless
Copy link

typeless commented Jul 21, 2023

By 'first run', I mean running Tup when .tup has not been created.

To reproduce, create a simple Tupfile as follows:

import FOO="Something wrong!"
: |> echo $(FOO) |>
$ touch Tupfile.ini
$ FOO=hello tup  # Expecting 'hello', got 'Something wrong!'
$ FOO=hello tup  # Expecting no action, got `Environment variable changed: FOO` and 'hello'
$ rm -rf .tup    
$ FOO=hello tup  # Expecting 'hello', got 'Something wrong!'
@petemoore
Copy link
Contributor

On macOS I cannot reproduce this. I tried with both latest HEAD revision from Fri Sep 15 20:42:54 2023 -0700 (8739d02) and also with an older version from Sat Jul 30 13:07:49 2022 -0700 (b037d4b).

In both cases, I get the expected behaviour:

pmoore@Peters-MacBook-Pro:~/Desktop/tmp $ touch Tupfile.ini
pmoore@Peters-MacBook-Pro:~/Desktop/tmp $ vi Tupfile
pmoore@Peters-MacBook-Pro:~/Desktop/tmp $ FOO=hello tup
Initializing .tup in /Users/pmoore/Desktop/tmp
.tup repository initialized: .tup/db
[ tup ] [0.001s] Scanning filesystem...
[ tup ] [0.002s] Reading in new environment variables...
[ tup ] [0.002s] Parsing Tupfiles...
 0) [0.001s] .
 [ ] 100%
[ tup ] [0.022s] No files to delete.                                                                                                                                                                                                              
[ tup ] [0.023s] Executing Commands...
 0) [0.007s] echo hello                                                                                                                                                                                                                           
hello
 [ ] 100%
[ tup ] [0.031s] Updated.                                                                                                                                                                                                                         
pmoore@Peters-MacBook-Pro:~/Desktop/tmp $ FOO=hello tup
[ tup ] [0.000s] Scanning filesystem...
[ tup ] [0.000s] Reading in new environment variables...
[ tup ] [0.000s] No Tupfiles to parse.
[ tup ] [0.000s] No files to delete.
[ tup ] [0.000s] No commands to execute.
[ tup ] [0.000s] Updated.
pmoore@Peters-MacBook-Pro:~/Desktop/tmp $ rm -rf .tup
pmoore@Peters-MacBook-Pro:~/Desktop/tmp $ FOO=hello tup
Initializing .tup in /Users/pmoore/Desktop/tmp
.tup repository initialized: .tup/db
[ tup ] [0.001s] Scanning filesystem...
[ tup ] [0.001s] Reading in new environment variables...
[ tup ] [0.002s] Parsing Tupfiles...
 0) [0.002s] .
 [ ] 100%
[ tup ] [0.024s] No files to delete.                                                                                                                                                                                                              
[ tup ] [0.026s] Executing Commands...
 0) [0.011s] echo hello                                                                                                                                                                                                                           
hello
 [ ] 100%
[ tup ] [0.039s] Updated.                                                                                                                                                                                                                         
pmoore@Peters-MacBook-Pro:~/Desktop/tmp $ tup --version
tup b037d4b211de6025703b77c3287b76159656ef22

and

pmoore@Peters-MacBook-Pro:~/Desktop/tmp $ rm -rf .tup
pmoore@Peters-MacBook-Pro:~/Desktop/tmp $ FOO=hello ~/git/tup/tup
Initializing .tup in /Users/pmoore/Desktop/tmp
.tup repository initialized: .tup/db
[ tup ] [0.001s] Scanning filesystem...
[ tup ] [0.002s] Reading in new environment variables...
[ tup ] [0.002s] Parsing Tupfiles...
 0) [0.001s] .
 [ ] 100%
[ tup ] [0.028s] No files to delete.                                                                                                                                                                                                              
[ tup ] [0.030s] Executing Commands...
 0) [0.008s] echo hello                                                                                                                                                                                                                           
hello
 [ ] 100%
[ tup ] [0.039s] Updated.                                                                                                                                                                                                                         
pmoore@Peters-MacBook-Pro:~/Desktop/tmp $ FOO=hello ~/git/tup/tup
[ tup ] [0.000s] Scanning filesystem...
[ tup ] [0.000s] Reading in new environment variables...
[ tup ] [0.000s] No Tupfiles to parse.
[ tup ] [0.000s] No files to delete.
[ tup ] [0.000s] No commands to execute.
[ tup ] [0.000s] Updated.
pmoore@Peters-MacBook-Pro:~/Desktop/tmp $ ~/git/tup/tup --version
tup v0.7.11-120-g8739d024
pmoore@Peters-MacBook-Pro:~/Desktop/tmp $ git -C ~/git/tup rev-parse HEAD
8739d02408b4e215bb419ae6dfbe17a76b5d0518

@typeless Can you provide details of which version you are running, and maybe uname -a and the sha256 of your tup binary, if you downloaded it, or if you built it, the revision you built it from, and any extra options you specified etc?

@typeless
Copy link
Author

Hi @petemoore
Here is what I did:

image

The tup executable is built by myself with CONFIG_TUP_SERVER=ldpreload in tup.config.

petemoore added a commit to petemoore/tup that referenced this issue Jan 18, 2024
Tup was previously calling getenv("FOO=bar") to retrieve envvar FOO
inside tup_db_findenv. This worked on macOS, but not on Linux. Updated
to call getenv(varname) instead (e.g. getenv("FOO")). Fixes gittup#483
@petemoore
Copy link
Contributor

petemoore commented Jan 18, 2024

Many thanks @typeless!

I was able to reproduce on Linux (the bug doesn't present under macOS) and have a fix up for review in #489.

Note: the CI failure above is unrelated.

petemoore added a commit to petemoore/tup that referenced this issue Jan 18, 2024
Tup was previously calling getenv("FOO=bar") to retrieve envvar FOO
inside tup_db_findenv. This worked on macOS, but not on Linux. Updated
to call getenv(varname) instead (e.g. getenv("FOO")). Fixes gittup#483
petemoore added a commit to petemoore/tup that referenced this issue Jan 18, 2024
Tup was previously calling getenv("FOO=bar") to retrieve envvar FOO
inside tup_db_findenv. This worked on macOS, but not on Linux. Updated
to call getenv(varname) instead (e.g. getenv("FOO")). Fixes gittup#483
@gittup gittup closed this as completed in 6a92109 Jan 25, 2024
gittup added a commit that referenced this issue Jan 25, 2024
@gittup
Copy link
Owner

gittup commented Jan 25, 2024

Thank you Mura for the report, and thank you Pete for the fix. I did have to adjust the fix slightly because strndup isn't available in MinGW for some reason, so hopefully I didn't mess it up. I also added a test case (t2243) to check for this behavior.

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 a pull request may close this issue.

3 participants