scons icon indicating copy to clipboard operation
scons copied to clipboard

SCons doesn't warn about missing CacheDir or its parents

Open bdbaddog opened this issue 7 years ago • 2 comments

This issue was originally created at: 2013-04-26 02:42:45. This issue was reported by: dheinrichs.

dheinrichs said at 2013-04-26 02:42:45

When trying a simple Java build on Windows, SCons always rebuilds unconditionally:

C:\Users\dhs\scons_test>scons -Q
 
scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "C:\Users\dhs\scons_test\SConstruct", line 2, in <module>
C:/jdks/1.7/jdk/bin/javac.exe -d classes -sourcepath src src\Hello.java
 
C:\Users\dhs\scons_test>scons -Q
 
scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "C:\Users\dhs\scons_test\SConstruct", line 2, in <module>
C:/jdks/1.7/jdk/bin/javac.exe -d classes -sourcepath src src\Hello.java

If I rebuild again, adding --debug=explain, I get this:

C:\Users\dhs\scons_test>scons -Q --debug=explain
 
scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "C:\Users\dhs\scons_test\SConstruct", line 2, in <module>
scons: Cannot explain why `classes\Hello.class' is being rebuilt: No previous build information found
C:/jdks/1.7/jdk/bin/javac.exe -d classes -sourcepath src src\Hello.java
 
C:\Users\dhs\scons_test>dir
 Volume in Laufwerk C: hat keine Bezeichnung.
 Volumeseriennummer: 78ED-C3A6
 
 Verzeichnis von C:\Users\dhs\scons_test
 
26.04.2013  11:35    <DIR>          .
26.04.2013  11:35    <DIR>          ..
26.04.2013  11:35               915 .sconsign.dblite
26.04.2013  11:35    <DIR>          classes
24.04.2013  15:03                44 SConscript
24.04.2013  15:14               160 SConstruct
24.04.2013  14:55    <DIR>          src
               3 Datei(en),          1.119 Bytes
               4 Verzeichnis(se), 211.825.582.080 Bytes frei

If I run the same build on Linux, it works as expected:

% scons -Q
/usr/bin/javac -d classes -sourcepath src src/Hello.java
% scons -Q
scons: `.' is up to date.

bdbaddog said at 2013-04-26 12:15:06

I notice that you've not brought this issue up in any mailing list. You will get far more eyes on your problem (which could be an issue with your configuration), if you explain your issue in the users mailing list first.

dheinrichs said at 2013-04-29 07:48:48

The problem was caused by using \ in the cache dir path. After changing the call from

    CacheDir('C:\Temp\build_cache')

to

    CacheDir('C:/Temp/build_cache')

it started working as expected.

As I was asked to file a bug about this, I changed this one accordingly.

weegreenblobbie said at 2013-05-02 10:02:00

I've ran into the same issue for our C++ project, I used the following workaround, as already suggested, replacing \ with / solves the issue:

cache_dir = Dir(".").get_abspath()
cache_dir = cache_dir.replace("\\", "/")
build_env.CacheDir(cache_dir)

weegreenblobbie said at 2013-05-02 10:03:47

Ooops, that should have been:

cache_dir = Dir("cache_dir").get_abspath()
cache_dir = cache_dir.replace("\\", "/")
build_env.CacheDir(cache_dir)

garyo said at 2013-05-03 07:30:02

I thought I understood this, but now I'm not so sure. Your original example has an incorrect Python string due to failing to double backslashes in a literal python string:

  CacheDir('C:\Temp\build_cache')

The third character of 'C:\Temp\build_cache' is an ASCII TAB (\t), and \b means backspace, so the 7th character is a backspace. The resulting string contains no backslashes, and certainly doesn't describe a valid filesystem path. That's what I thought was causing the problem.

But later you do this:

  cache_dir = Dir(".").get_abspath()
  cache_dir = cache_dir.replace("\\", "/")

That first cache_dir should be already correct. It's not a Python literal string so there should be no backslash interpretation problem (i.e. the string should have a drive letter and an actual backslash as the third character). There should be no need to replace actual backslashes in a string with forward slashes.

So if this is failing, it's due to some other problem. Could you post a complete failing C/C++ example?

dheinrichs said at 2013-05-03 07:33:01

Nick Hilton != Dirk Heinrichs

weegreenblobbie said at 2013-05-03 08:53:21

I'm looking into it ...

weegreenblobbie said at 2013-05-03 10:42:02

Disregard my comments, I can not reproduce the problem today.

I am sharing my Linux home directory, mounting a network drive on my Windows box, and building with scons in Linux also. I'm betting it was a funny interaction going between the two.

garyo said at 2013-05-04 05:16:34

OK, got it. I'm pretty sure the problem is related to the wrong use of backslash-escapes in a literal python string causing the cache dir (and its parents) to be nonexistent, and SCons failing to warn about that. I'll change the title of the bug accordingly.

dheinrichs said at 2013-05-04 06:07:09

And of course it shouldn't do unconditional rebuilds if it thinks the cache is absent.

bdbaddog avatar Jan 02 '18 15:01 bdbaddog

Okay, not getting this problem.

First - I think the link from a PR was a typo - the reference here says "Fix Issue 2904" but that was really 2906 - which indeed was relevant and was closed at the time.

The revised topic line says doesn't warn about missing cachedir or parents, but those will be created if needed. So it's something different, like if the cachedir argument is somehow empty? is it a doc problem that if you use Windows paths and don't enter them either as rawstrings or as slash-escaped, then you're in trouble?

mwichmann avatar May 14 '21 23:05 mwichmann

Current code using tempfile.mkdtemp indeed does not create intermediate directories, so this is broken again - but there's certainly a warning, in fact, a hard failure.

mwichmann avatar Nov 01 '25 15:11 mwichmann