Why does configure.sh think win32 is Unix? - build-process

I'm trying to build an application from source in windows that requires some Unix tools. I think it's the apparently standard ./configure; make; make install (there's no INSTALL file). First I tried MinGW but got confused that there was no bash, autoconf, m4, or automake exes in \bin. I'm sure I missed something obvious but I installed Cygwin anyways just to move forward. For some reason when I run
sh configure.sh
I get:
platform unix
compiler cc
configuration directory ./builds/unix
configuration rules ./builds/unix/unix.mk
My OS has identity problems. Obviously the makefile is all wrong since I'm not on unix but win32. Why would the configure script think this? I assume it has something to do with Cygwin but if I remove that I can't build it at all. Please help; I'm very confused.
Also is it possible to build using MinGW? What's the command for bash and is mingw32-make the same as make? I noticed they're different sizes.

Everything is fine. When you are inside CygWin, you are basically emulating an UNIX. sh runs inside CygWin, and thus identifies the OS correctly as Unix.
Have a look at GCW - The Gnu C compiler for Windows

Also, you might be interested in this help page, that goes into some detail about the minimal system (MSYS), such as how to install, configure et. c.
That should help you get bash, configure and the rest to work for MinGW as well.

From the Cygwin home page
Cygwin is a Linux-like environment for Windows. It consists of two parts:
A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality.
A collection of tools which provide Linux look and feel.
Since configure is using the Cygwin environment, it is interacting against the emulation layer and so it is just like it's working on a Unix environment.
Have you tried building the application and seeing if it works?

Related

Can I use zsh as the default non-interactive shell for WSL2 Ubuntu?

I am trying to use Run/Debug Configurations on WebStorm, however it doesn't seem to source .zshrc and produces errors about not finding commands and environment variables. (An example of this would be yarn tauri dev when using Tauri)
I have installed Ubuntu 20.04 in WSL and the project I opened in WebStorm resides under the $HOME directory. WebStorm is installed in Windows.
For the interactive shell, I have made zsh the default by chsh -s $(which zsh), but when using Run/Debug Configurations it uses the default non-interactive shell, which is dash as far as I know. And my environment variables and PATH are all set in .zshrc, which is not sourced by dash.
It seems in CLion, it is possible to execute commands in the login shell according to this YouTrack issue, but such an option is not available on WebStorm.
Is it possible to use zsh instead of dash as the default non-interactive shell? If not, it would help me a lot to know what is the best practice in such situations.
There are several questions and points you make:
First, from the question title (and the summary at the end):
Can I use zsh as the default non-interactive shell for WSL2 Ubuntu?
Well, maybe (using symlinks), but it would be a really bad idea. So many built-in scripts rely on /bin/sh pointing to Dash, or at least Bash. While Zsh might be compatible with 99.9% of them, eventually there's a strong likelihood that some difference in Zsh would cause a system-level script to fail (or at least produce results inconsistent with those from Dash).
It is possible in Ubuntu to change the default non-interactive ("system" shell) from Dash to Bash with sudo dpkg-reconfigure dash. If you select "No" in the resulting dialog, then the system will be updated to point /bin/sh to bash instead of dash.
But not to Zsh, no.
when using Run/Debug Configurations it uses the default non-interactive shell, which is dash as far as I know
I don't run WebStorm myself, so I'm not sure on this exactly. Maybe #lena's answer (or another) will cover it for you, but if it doesn't, I'm noticing this doc page. It might be worth trying to specify Zsh in those settings, but again, I can't be sure.
And my environment variables and PATH are all set in .zshrc, which is not sourced by dash.
Hmm. I'm guessing you would need these set in a .profile/.zprofile equivalent regardless. I would assume that WebStorm is executing the shell as a non-interactive one, which means that it wouldn't even parse ~/.bashrc if Bash was your default shell.
... it would help me a lot to know what is the best practice in such situations.
Best practice is probably to make sure that your ~/.profile has any environment changes needed. Yes, this violates DRY (don't repeat yourself), but it's probably the best route.
Thanks to the answer here and the discussion below, I was able to figure it out. (Thank you, #NotTheDr01ds and #lena.)
The main problem is that WebStorm is installed on Windows and therefore knows only the environment variables in Windows. There are two ways to solve the problem as follows.
Sharing WSL's environment variable to Windows through WSLENV
Add the line below to .zshrc so that it sets $WSLENV when zsh starts.
export WSLENV=VAR_I_WANT_TO_SHARE:$WSLENV
# Don't forget to insert the colon
# And for some reason, appending the variable after $WSLENV didn't work well
In Windows, run
wsl -e zsh -lic powershell.exe
This runs WSL using zsh (logged-in and interactive), then runs powershell which brings you back to Windows. Although this doesn't seem to achieve anything, by going through zsh in WSL, .zshrc was sourced and therefore $WSLENV set as well. You can check if it worked well by running the below command after you've run the above.
$env:VAR_I_WANT_TO_SHARE
Run WebStorm from the PowerShell that was just created.
& 'C:\Program Files (x86)\JetBrains\WebStorm 2022.1.3\bin\webstorm64.exe'
When you run or debug any of the Run/Debug Configurations, you will see that the environment variable is shared successfully.
Setting the PATH in Windows
For most environment variables, the previous method works well. However, PATH is an exception. The Windows PATH is shared to WSL by default. The opposite doesn't work, probably because the PATH in WSL should not interfere with Windows.I've tried adding the $PATH of WSL into $WSLENV but it didn't seem to work.
In the end, what I did was manually adding each needed $PATH of WSL into the Windows PATH.
For example, if there was export PATH=$PATH:home/(username)/.cargo/bin in .zshrc, you can then add \\wsl$\Ubuntu\home\(username)\.cargo\bin to the Windows $env:Path using the Environment Variable window.
I might have made some mistakes, so feel free to leave an edit or comments.
You can try using npm config set script-shell command to set the shell for your scripts. Like npm config set script-shell "/usr/bin/zsh".
When npm run <script name> spawns a child process, the SHELL being used depends on NPM environment. Cм https://docs.npmjs.com/cli/run-script:
The actual shell your script is run within is platform dependent. By
default, on Unix-like systems it is the /bin/sh command, on Windows it
is the cmd.exe. The actual shell referred to by /bin/sh also depends
on the system. As of npm#5.1.0 you can customize the shell with the
script-shell configuration
See also https://github.com/npm/npm-lifecycle/blob/10c0c08fc25fea3c18c7c030d4618a401963355a/index.js#L293-L304

Unix command line on PC using Ubuntu

I am new to these forums and to using Ubuntu and linux and UNIX. I really need some help here. I hope I haven't shot myself in the foot already. I have been trying to complete a UNIX carpentry lesson on the internet for an assignment. I am learning the basics about UNIX. I am not using a Mac, I am using a PC that I did not configure in any way (maybe that's my problem). I am using windows 10 on a lenovo and trying to the command prompt on Ubuntu to find my desktop where a file called "data-shell" is located. The problem: IT IS NOT FINDING THE DESKTOP. Upon further inspection, I have been looking through the location of my desktop and "data-shell" file and found it in the Users location under a number 12094, which I am assuming is the serial number for the computer. I have NEVER fiddled with the software at all with this computer as it cost me a lot of money, but I really do not want to be stopped in the tracks already. I have the following images numbered in the order that I discovered everything; they are posted here. I would really appreciate the help. P.S.: Since I am using a PC and not mac, I thought I had to use another command line like BASH or the terminal on my PCor doI just use Ubuntu? The UNIX shell is supposed to start with a $, right? Please correct me if I a wrong and thank you for your help
.
linux commands on windows can be ran via cmder or git bash (what i had used in past)
and in linux the desktop is at the path
/home/< username>/Desktop
whereas in windows its
C:\Users<username>\Desktop
both windows (DOS) and ubuntu/mac(linux) environment are entirely different you can directly run commands of one on the other environment, you do need to "setup" that env first if the command is not native to that.
Now, since its assignments that you are doing and all you need is bare-min linux env
you can give https://repl.it/ a try and create a new project in bash
Also, when you install Ubuntu on windows you dont get acces to windows like path, like "C:...", in ubuntu c:\ of windows is mounted to some other path in ubuntu
search on google how to access windows desktop from ubuntu shell after installing ubuntu inside of windows
When using Windows Subsystem for Linux (WSL), your C drive is located under /mnt/c.
Judging from the screenshot, you are user 12094, so you can either accept this, or you need to actually configure your machine. Also if you look in the screenshot you provided, there is a /home folder which I am betting is actually pointing to /mnt/c/, and your home folder will be under /home/12094, which is also the same as what is stored in $HOME.
To find the location of a file called data-shell, you can run the following linux command while in your home folder:
find $HOME -type f -name 'data-shell'
This command recursively searches for files in your home directory, with the name data-shell

Execute this command line in Windows

I'm trying to connect my firebase auth to an expo project.
I'm following the main docs of each library. I'm stucking on this step.
I'm not able in windows to exeute this command line openssl rand -base64 32 | openssl sha1 -c.
I've tried with the specific https://code.google.com/archive/p/openssl-for-windows/downloads but I don't know how to reproduce the same line.
Any help would be great, thanks in advance.
You need to install openssl. It is usually available on Linux (which I think that article might have been written for). There are some Windows binaries available at here. Alternatively, you could setup a WSL session, and run the command from there.
that is a linux command. Therefore a linux terminal is needed.
there are at least 2 ways to get this done
using virtual machine with ubuntu or some other operating system that uses a linux terminal aka shell (which I doubt you know about)
OR
installing a linux emulator (windows 8+ since it's from the windows store)
assuming you would prefer option 2, go to the windows store, search "Kali" and you will find an app called Kali. install it and if an error shows up, here's a nice video here that talks about solving that error and you would have a kali terminal on your windows computer (your command would work there)

rsync fail because of file permission

I was using a dual boot system and backing up in Linux my files using rsync and link-dedt and everything was working perfectly. Because the computer is mostly logged in Windows I decided to install cygwin and try to use rsync to do my backups. That way I can have a script that runs automatically every week. However when I tried to continue my backup using link-dest in cygdrive it didn't work. I think is because the files permission are seen differently by cygwin and Linux.
My command was something like:
rsync -av --exclude-from=exclude.txt --progress --link-dest=/cygdrive/e/2016-02-19/ /cygdrive/d/Users/ /cygdrive/e/2016-02-24/
I looked at files that I knew didn't change in the link-dest and source location and everything looks the same except for the file persmission. How can I omit permissions or solve this problem?
Cygwin on windows does cause lots of strange permissions.
If i was backing windows to a linux host, i would use https://acrosync.com/ which is native rsync for windows, unfortunately it does cost money.
We gave up on cygwin rsync partially due to these issues and ended up developing our own windows replication tool http://www.yintersync.net. Its free for non-commercial use.

How do I initialize LLVM's external symbolizer?

When compiling with -fsanitize=memory I get WARNING: Trying to symbolize code, but external symbolizer is not initialized! when running the program. How do I initialize the external symbolizer?
I solved my own problem using MSAN_SYMBOLIZER_PATH=$(which llvm-symbolizer-3.4) ./a.out. The problem is that Ubuntu postfixes the version number but the binary doesn't know that. Of course you need to use MSAN instead of ASAN when using the memory sanitizer.
You are supposed to be able to set the ASAN_FILTER environment variable to point at a symbolizer, but I could not get it to work. However, you can redirect stderr into a symbolizer after the fact. You'll still get the warnings about the uninitialized symbolizer, but the filenames and line numbers will be correct.
You can use asan_symbolizer.py as the external symbolizer. After downloading it from that link (to /tmp, for example), invoke your program like so (in bash, for this example):
./myprogram 2>&1 | /tmp/asan_symbolize.py | c++filt
On my Ubuntu system, the issue is that LLVM's tools are installed under /usr/bin with version suffixes (like llvm-symbolizer-4.0), and the sanitizer tools are looking for them without version suffixes.
LLVM also installs its binaries to, e.g., /usr/lib/llvm-4.0/bin; the tools under /usr/bin are actually just symlinks. So an easy solution is to add the appropriate /usr/lib/llvm-*/bin directory to your path when working with sanitizers.
I received such warning when I run program debug version (compiled with -fsanitize=address) on Linux machine that didn't contain clang installation. The problem disappeared after I installed clang from devtoolset.

Resources