SCons carshed when option is given value containing a colon - scons

On Windows, when I pass an argument to SCons (added using AddOption) that contains ':', Scons exits with error code 2 and doesn't compile. All steps prior to compilation are executed.
scons --test_option="abc:" # Fails
scons --test_option="abc" # Works
It doesn't work even when the option itself is unused.
Colon is passed in the first place to provide full path. However it seems not to be path related.
Version: 2.2

Related

Wine + Cygwin garbles argv

I'm trying to compile a program (sbcl to be precise) under Wine + MinGW/Cygwin environment. I've fixed plethora of different quirks, but now I'm stuck on the fact that this environment breaks command line arguments in weird way. The problem is that build shellscript contains the lines
./src/runtime/sbcl --core output/cold-sbcl.core \
--lose-on-corruption $SBCL_MAKE_TARGET_2_OPTIONS --no-sysinit --no-userinit \
--eval '(sb-fasl::!warm-load "src/cold/warm.lisp")' --quit
...but within the running sbcl process the last command line argument appears as (sb-fasl;!warm-load "src/cold/warm.lisp"), which is, of course, syntactically incorrect and the build fails.
I've performed some tests with different versions of wine (I've tried versions 6.0, 6.12 and 6.15) and win32 bash (I've tried a plenty of those, including busybox for windows, currently stuck with the one from old MSYS-20111123.zip from here since it does not exhibit FAST_CWD bug that is currently not fixed). It appears that every time the command line contains both double colon and forward slash, some part of the environment changes double colon to semicolon. I'm not sure where to look for that behaviour to circumvent it - is that shell escaping, or exec syscall behaviour? Could it be that this behaviour is hardcoded into exec function in msvcrt.dll?

Node and npm are installed but Git bash doesn't recognize 'node' inside 'npm run dev' (other shells work fine)

I have npm and node installed (tried NVM for Windows and direct installations).
When running 'npm -v' or 'node -v' in Git Bash everythings works fine. But when I try to run 'npm run dev' (or any other command) the output says that 'node command is not recognized'.
In other shells (CMD/Powershell) everything works fine.
I've checked Path variable in Windows, Path variable in Git Bash, everything seems to be correct.
Error screenshot
Path variable screenshot
Path variables cmd/procmon
Any help appreciated.
p.s. While I was trying to find an answer I saw the same question from #jameseg , maybe if he sees this one he could help.
Your PATH environment variable is quite a mess. It has duplicate entries, also has an entry C:\Program Files\nodejs\node.exe which is not valid because it should be a folder, not a file, and it has . in the middle which doesn't make much sense either.
But the main problem is that it has a stray doublequote, after C:\Program Files\Java\jdk-13.0.1\bin:
With this, effectively all the paths after it are ignored, because they are treated as part of one big quoted string (which is implicitly terminated by the end of the variable data).
To illustrate what I mean, consider this example:
This correct PATH variable...
C:\a;C:\b;"C:\c 123";C:\d;C:\e
...is interpreted as:
C:\a
C:\b
C:\c 123
C:\d
C:\e
But, this bad PATH variable where I deleted one of the quotes...
C:\a;C:\b;C:\c 123";C:\d;C:\e
...is interpreted like this:
C:\a
C:\b
C:\c 123";C:\d;C:\e
This may at first make only half sense, but it's because of the quirky way Windows parses this variable: When encountering a doublequote, it's removed from the result but toggles a flag that says whether we are now inside a quoted string. And when the flag is set, semicolons are ignored. So even if the stray quote is at the end of a path (or in the middle of it), it will have the effect of essentially quoting the rest of the variable data until the next doublequote or the end of the data.
Confusingly, you may still have where node report that it found node, because the where.exe tool does its own parsing, in a slightly different way (ignoring quotes), so you cannot rely on its output! (For example, try set PATH=c:\win""dows. where explorer will say it can't be found, yet explorer will work to open Explorer. You get the opposite with something like set PATH=x"y;c:\windows - where explorer will list c:\windows\explorer.exe, yet explorer will not work.) The reason why it works in Git Bash is probably the same: when the environment variables are translated to UNIX paths, they are parsed slightly differently than Windows would do it itself, inadvertently correcting the problematic entry in the process.
So, the solution is to remove this doublequote from your path variable.

Coq makefile "Top." Prefix

I am using the automatic Coq 8.5 makefile generator. This makefile prefixes all modules by "Top." .
Now let's say you run a lot of files by make and then want to change/debug some file in the IDE.
Then the annoying fact is that Coq complains it cannot find the compiled other files, because in the IDE it assumes the names without the "Top" prefix.
I tried to tweak the makefile to get rid of this prefix. But I always ended in some error message of the make.
Can someone show me either how to remove "Top" prefix in make or tell the IDE to use the "Top" prefix.
You can start CoqIDE with the following arguments coqide -R . Top.
This will get rid of the following error Error: The file ..../Logic.vo contains library Top.Logic and not library Logic.
This is annoying indeed. In order to avoid that kind of annoyance, always start your _CoqProject with a line listing options:
-Q . MyProject
To note: the options you can put on the first line of your _CoqProject are the ones listed when calling coqtop -help.

Set linker search path for build in CMake

It seems this question has been asked very often before but none of the solutions seem to apply in my case.
I'm in a CMake/Linux environment and have to run an executable binary during the build step (protoc in particular).
This binary needs a library but it's not installed (and cannot be) in the in the standard directories like /usr, so the library cannot be found.
Unfortunately I cannot manipulate the protoc call because it's embedded in a 3rd party script.
I can now set LD_LIBRARY_PATH before every make or set it system wide but this is very inconvenient especially when it comes to IDEs in which the build takes place or distributed build scenarios with continuous build environments.
I tried to set LD_LIBRARY_PATH via
set(ENV{LD_LIBRARY_PATH} "/path/to/library/dir")
but this seems to have no effect during the build step.
So my question is: can I set a library search path in CMake which is used during the build?
Try this
SET(ENV{LD_LIBRARY_PATH} "/path/to/library/dir:$ENV{LD_LIBRARY_PATH}")
I also used this dirty trick to temporary change some environment variables:
LD_LIBRARY_PATH="/path/to/library/dir:$LD_LIBRARY_PATH" cmake ...
After execution of this line LD_LIBRARY_PATH is not changed in the current shell.
Also, I do not find it bad to change LD_LIBRARY_PATH before invoking cmake:
export LD_LIBRARY_PATH=...
It won't change anything system-wide, but it would be used for your current shell, current build process. The same holds for CI builds. You can save the variable and restore it after cmake invocation:
MY_LD=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=...
cmake...
export LD_LIBRARY_PATH=$MY_LD
I have recently run into a somewhat similar problem.
My solution was to incorporate sourcing a file that set the appropriate environment into every command.
For example, this custom command:
add_custom_command(
OUTPUT some_output
COMMAND some_command
ARGS some_args
DEPENDS some_dependencies
COMMENT "Running some_command some_args to produce some_output"
)
Would become:
set(my_some_command_with_environment "source my_environment_script.sh && some_command")
add_custom_command(
OUTPUT some_output
COMMAND bash
ARGS -c "${my_some_command_with_environment} some_args"
DEPENDS some_dependencies
COMMENT "Running some_command some_args to produce some_output"
VERBATIM
)
Obviously, this has some disadvantages:
It relies on a bash shell being available.
It sources the environment script for every command invocation (performance issue) and you will have to change all invocations of commands that rely on that environment variables.
It changes the normal syntax of having the command follow COMMAND and the arguments follow ARGS, as now the 'real' command is part of the ARGS.
My CMake-Fu has proven insufficient to find a syntactically nicer way of doing this, but maybe somebody can comment a nicer way.
I had a similar issue for an executable provided by a third party library. The binary was linked against a library not provided by the distribution but the required library was included in the libs directory of the third party library.
So running LD_LIBRARY_PATH=/path/to/thirdparty/lib /path/to/thirdparty/bin/executable worked. But the package config script didn't set up the executable to search /path/to/thirdparty/lib for the runtime dependent so CMake would complain when CMake tried to run the executable.
I got around this by configuring a bootstrap script and replacing the IMPORTED_LOCATION property with the configured bootstrapping script.
_thirdpartyExe.in
#!/bin/bash
LD_LIBRARY_PATH=#_thirdpartyLibs# #_thirdpartyExe_LOCATION# "$#"
CMakeLists.txt
find_package(ThirdPartyLib)
get_target_property(_component ThirdPartyLib::component LOCATION)
get_filename_component(_thirdpartyLibs ${_component} DIRECTORY)
get_target_property(_thirdpartyExe_LOCATION ThirdPartyLib::exe IMPORTED_LOCATION)
configure_file(
${CMAKE_CURRENT_LIST_DIR} _thirdpartyExe.in
${CMAKE_BINARY_DIR}/thirdpartyExeWrapper #ONLY
)
set_target_properties(ThirdPartyLib::exe PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/thirdpartyExeWrapper)
Honestly I view this as a hack and temporary stop gap until I fix the third party library itself. But as far as I've tried this seems to work on all the IDE's I've thrown at it, Eclipse, VSCode, Ninja, QtCreator, ... etc

Cygwin make error : *** target pattern contains no `%'

I got this error while (re)building, using cygwin make.exe version :3.81.
Error : *** target pattern contains no `%'.
This error is due to a presence of a ":". Therefore it no longer supports windows paths.
You need to download version 3.80 and replace the make.exe in the \bin directory.
Apparently it needs cygintl12.dll too.
rollback to make 3.80 (Geant4)
cd /usr/bin
mv make.exe make_381.exe
wget http://geant4.cern.ch/support/extras/cygwin/make.exe
chmod +x make.exe
install libintl2 from cygwin setup for the required cygintl-2.dll
I got the same error when trying to build a project on Linux or OSX, that was previously built on a Windows machine and had some .o.d files hanging around in the output folder.
Once I manually deleted the .o.d files the problem was resolved. Apparently the "Clean" command of my IDE (CodeLite in this case) wasn't deleting the .o.d files.
Most likely due to the presence of a colon following a drive letter. For example consider
build : $(NativeHeaders)/*
If
NativeHeaders=../../../cpp/generated
then all is well, but
NativeHeaders=C:/dev/folder/cpp/generated
results in the error that you get.
I was getting this error because I didn't have a Tab (\t) character at the beginning of my commands. I had expandtab in my vim set so it was replacing a tab character with 4 spaces. When I turned that off and changed spaces to a tab it was fixed
I had the target pattern contains no '%' error while building with the Android NDK using cygwin.
I found the following link helpful:
Errors Generated by Make
‘missing target pattern. Stop.’
‘multiple target patterns. Stop.’
‘target pattern contains no `%'. Stop.’
‘mixed implicit and static pattern rules. Stop.’
These are generated for malformed static pattern rules. The first means there’s no pattern in the target section of the rule; the second means there are multiple patterns in the target section; the third means the target doesn’t contain a pattern character (%); and the fourth means that all three parts of the static pattern rule contain pattern characters (%)–only the first two parts should. If you see these errors and you aren’t trying to create a static pattern rule, check the value of any variables in your target and prerequisite lists to be sure they do not contain colons. See Syntax of Static Pattern Rules.
And so, my solution included changing my system variables from Windows format to Unix format like so:
Instead of C:\Android\android-ndk-r10c, I used /cygdrive/c/Android/android-ndk-r10c for the NDK path.
Similarly, I changed the NDK project path to /cygdrive/c/Android/project/src/main/jni.
In my case I was using CMake under Cygwin when I got this error. It turned out the Windows version of CMake was executed. Subsequently, Windows paths were used in the make file. I installed Cygwin's version of CMake through the setup program and got it working.
I had this problem on Linux when the build directory contained a ":" caused by doing a mercurial checkout which created a directory named "server:port".
I had to change the following in my make file to be compatible with Make_381:
before:
ARDUINO_BASE_DIR = C:\programs/arduino
now:
ARDUINO_BASE_DIR = \\programs/arduino
Try this if you're running Eclipse C/C++ and referencing files from Cygwin under Windows, make sure c:/cygwin/bin or c:/cygwin64/bin comes after your preferred compiler tools in your Windows Path environment.
Example:
Path = ;C:\yagarto\bin;C:\yagarto-tools\bin;C:\cygwin64\bin;
After making the changes, exit Eclipse and restart for it to take effect (simply restarting Eclipse without exiting won't fix the problem.
In my project, obj folder was probably corrupted and I was getting this error. Manually deleted obj folder. Then ndk-build completed fine.

Resources