Open ebeshero opened 2 years ago
This works just fine, but requires some careful configuration and moving between different command shells on your computer. WSL creates a Linux subsystem on your computer, and we can use it to run the build process so it doesn't warp the file path information that staticSearch depends on to build its search page.
Install WSL, using the Windows CMD shell. Instructions: https://learn.microsoft.com/en-us/windows/wsl/install
Once WSL is configured, you can open the Ubuntu shell and navigate around your file system. Ubuntu makes its own space on your computer, so you won't immediately see your Windows files. To find them, you need to navigate over to the Windows "mount" or drive. See https://learn.microsoft.com/en-us/windows/wsl/filesystems for details.
Keep in mind:
lib/
folder) can stay exactly where it is. We'll just tell Ubuntu's environment how to find ant. And we'll navigate in Ubuntu over to your installation of staticSearch to run ant
.You need a new installation of Java over here, because Linux does things differently than Windows. Fortunately this is very easy because we handle the download and installation all at once with shell commands in Linux.
sudo apt update
(to update the available packages to install)java -version
(probably it isn't). sudo apt install default-jdk
java -version
again (should be there now). You'll have an OpenJDK distribution, which is default for Linux systems. ====================
Use cd
and ls
to navigate and look: see if you have a Java installation here. Right now, my java installation path looks like this:
/usr/lib/jvm/java-1.11.0-openjdk-amd64
Your version of java might be different, so notice and copy-paste whatever it is somewhere that you can use it again. We'll set your Ubuntu JAVA_HOME variable to point to this location.
Work with cd
and ls
to figure this out: You can get into your windows file system by switching over to it. If your Ant and GitHub are on the C:
drive on your computer, start the path with /mnt/c/
and continue looking from there. Copy this path carefully so you can use it again in the steps below.
Example: Here's how I can find my ant installation from my Linux subsystem:
cd /mnt/c/Users/ebbon/ant/apache-ant-1.10.12
So, the file path I'll need will be: /mnt/c/Users/ebbon/ant/apache-ant-1.10.12
This is basically the same idea as editing Windows' environment variables, only we do this with a text editor connected to the Ubuntu shell. We'll use the nano editor.
In the Ubuntu shell, you need sudo (superuser administrator) privileges to write and edit environment variables. This is where you'll use your WSL username and password.
Enter this command to edit your Ubuntu environment variables:
sudo nano /etc/environment
We'll do a couple of things here. We'll set the JAVA_HOME variable and the ANT_HOME variable.
Add a new line to the bottom of the environment file to read something like this (only change it to point to your specific path to your Java that you copied down earlier:
JAVA_HOME="/usr/lib/jvm/java-ENTER_WHATEVER_YOU_HAVE_HERE"
Now add the ANT_HOME variable in the next line.
ANT_HOME="/mnt/c/Users/ebbon/ant/apache-ant-1.10.12"
Note: I also added the ant file-path to the end of the PATH variable at the top of the file.
One more thing. Let's make it as easy as possible to navigate over to the staticSearch GitHub repo on your computer over on Windows. Use your cd
and ls
commands to figure out where it is and get that path, and let's enter a couple of simple alias variables, so you just type a simple word and it navigates immediately to GitHub, and another word will get you to staticSearch.
An alias line for easy navigation basically gives the word you want to type, an =
and then in quotation marks, the cd
command to the literal filepath it stands for. I'll show two aliases in my example script below. Keep in mind these are configured for my computer and your paths will probably be a little different.
**Update: I noticed my Ubuntu shell wasn't responding to me entering the ant
command. But it worked if it indicated the path to it by entering $ANT_HOME/bin
. So I saved one last alias to make sure the ant
command does what we need it to do (which is run the ant file in its bin/
folder).
============================= My /etc/environment file now looks like this:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Users/ebbon/ant/apache-ant-1.10.12:/usr/lib/jvm/java-1.11.0-openjdk-amd64/bin"
JAVA_HOME="/usr/lib/jvm/java-1.11.0-openjdk-amd64"
ANT_HOME="/mnt/c/Users/ebbon/ant/apache-ant-1.10.12"
alias GitHub="cd /mnt/c/Users/ebbon/Documents/GitHub"
alias static="cd /mnt/c/Users/ebbon/Documents/GitHub/staticSearch"
alias ant="$ANT_HOME/bin/ant"
In your Ubuntu shell, you need to refresh it to recognize the new info you just added.
To do that, enter: source /etc/environment
Then try out your aliases first of all. Do they help you navigate quickly over to the staticSearch/
repo?
ant
works to build staticSearchIn the Ubuntu shell, navigate to staticSearch (use your alias)!
Run ant
See if the build process completes and generates its search.html page in the /test
directory.
Read the error messages carefully. What do you think is wrong?
Huzzah! Now go to your Git Bash shell and if you have Python 3 installed, you can run the web server to read the configured website in the test directory. NOTE: Python 3 probably came with your Ubuntu installation, so you can run this next command in Ubuntu:
Run python -m http.server 8000
Out in Windows, open a web browser (like Chrome or Firefox) to localhost:8000
and check out your successfully built page.
At heading: Last step! Test whether ant works to build staticSearch I had an issue running 'ant'.
I got an issue: "Command 'ant' not found, but can be installed with: sudo apt install ant"
So, I ran: sudo apt install ant Then refreshed Ubuntu, but got an issue with the Buildfile (could not be found) BUILD FAILED
@erinmooney We worked on this after class and found out a few things: Your system was not reading the environment path we'd set back to ant on the Windows side of your machine due, alas, to spaces in the directory path! So! We ran with your solution: installing ant on the Ubuntu linux environment.
We found your new Linux ant over in usr/share/
and that is where we copied the ant-contrib jar file, using shell commands in the Ubuntu shell.
For all reading this: you may not need to take these steps, but note there may be complications if your filepath to your Windows ant installation contains spaces! Erin and I are troubleshooting this.
Downloading WSL on Windows 10 is the same process but you need to run the wsl --install
command on Powershell. When opening PowerShell, run it as administrator.
When editing the system variables using sudo nano /etc/environment
Press F3 and then Enter to save the added lines. To exit press ^X at the same time, you will probably need to hold shift when doing this.
The last step I am missing is installing Python 3. I don't know if Pycharm and Python 3 are different, the configured Pycharm I had was on my former laptop, and I'm unsure if I need to configure it for this project. I also don't recall what I did to configure it.
Pretty sure I am having the same issue that Erin was having when attempting to run ant in ubuntu
@tec5271 We discovered the issue here was with Ubuntu locating the ant files. You had let Ubuntu go ahead and install ant, so we solved this by copying your ant-contrib jar file over to the apache-ant installation in /usr/share/...
(This is where Ubuntu actually installs ant.) If anyone else is having this problem:
Use cd /usr/share
and then ls
to look inside. You should find apache-ant in there. Inside that is the lib/
folder where ant-contrib would go. We used the cp
command to copy from the /mnt/c/...path-to-ant/lib/ant-contrib.jar
to /usr/share/apache-ant.../lib
You might not have to do that cp command at all. We could have tried sudo apt-install ant-contrib
and that would probably have worked in Ubuntu.
NOTE: If Python isn't running over in Windows, you probably have Python3 in Ubuntu already. You can run the web server by navigating to staticSearch and into the test/
directory inside. Then (in Ubuntu shell) run:
python3 -m http.server 8000
That should run the web server for you.
We know the build will fail on Windows machines running ant on staticSearch "out of the box." The developers are aware of this but didn't have Windows machines available to help them debug it. We may be able to fix it and contribute solutions.
[x] Option 1: Install WSL (Windows Subsystem for Linux): which lets you run Linux on your Windows machine: The process should run fine inside that system. (Basically this sets up a Linux shell that you can use to run the build process for staticSearch): https://pureinfotech.com/install-wsl-windows-11/
WSL works to run staticSearch, so that's the option we're running with for now.
[ ] Option 2: Patch a few files: Get ant to read and convert Windows file paths to Unix-style paths, and contribute a patch for the developers. Ant itself has some pretty good documentation on how to cope with Windows file path syntax: https://ant.apache.org/manual/Tasks/pathconvert.html
I've tried a few things so far to try to patch the Windows build.xml, and I'm not finding the right combination yet.