Installed go with hombrew, can find $GOROOT causing package failures - unit-testing

I installed Go with homebrew and it usually works. Following the tutorial here on creating serverless api in Go. When I try to run the unit tests, I get the following error:
# _/Users/pro/Documents/Code/Go/ServerLess
main_test.go:6:2: cannot find package "github.com/strechr/testify/assert" in any of:
/usr/local/Cellar/go/1.9.2/libexec/src/github.com/strechr/testify/assert (from $GOROOT)
/Users/pro/go/src/github.com/strechr/testify/assert (from $GOPATH)
FAIL _/Users/pro/Documents/Code/Go/ServerLess [setup failed]
Pros-MBP:ServerLess Santi$ echo $GOROOT
I have installed the test library with : go get github.com/stretchr/testify
I would appreciate it if anyone could point me in the right direction.
Also confusing is when I run echo $GOPATH it doesnt return anything. same goes for echo $GOROOT

Some things to try/verify:
As JimB notes, starting with Go 1.8 the GOPATH env var is now optional and has default values: https://rakyll.org/default-gopath/
While you don't need to set it, the directory does need to have the Go workspace structure: https://golang.org/doc/code.html#Workspaces
Once that is created, create your source file in something like: $GOPATH/src/github.com/DataKid/sample/main.go
cd into that directory, and re-run the go get commands:
go get -u -v github.com/stretchr/testify
go get -u -v github.com/aws/aws-lambda-go/lambda
Then try running the test command again: go test -v
The -v option is for verbose output, the -u option ensures you download the latest package versions (https://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies).

Related

Create PDF reports using R Markdown (TinyTeX) in Snakemake using Conda

I am currently having problems using TinyTeX in a conda environment with Snakemake. I have to install TinyTeX installation files using the command tinytex::install_tinytex() before running the pipeline. This installs TinyTeX outside of the created environment (which isn't that big of a problem... but not preferred either) . The main problem is that every time I execute my Snakemake pipeline it will try to reinstall this installation which I don't want. Could anyone tell me what the easiest way is for me to check whether it's installed already? Should I be using the command Rscript -e \"tinytex:::is_tinytex()\" with an if-statement? And what is the best way to write that if-statement by calling Rscript -e in Snakemake? Or should I just write a boolean text-file on first run which specifies whether TinyTeX has been installed before?
It kinda sucks that the TinyTeX conda dependency doesn't work on its own without additional installation...
Snakemake rule (ignore input/output):
rule assembly_report_rmarkdown:
input:
rules.assembly_graph2image_bandage.output,
rules.assembly_assessment_quast.output,
rules.coverage_calculator_shortreads.output,
rules.coverage_calculator_longreads.output
output:
config["outdir"] + "Hybrid_assembly_report.pdf"
conda:
"envs/r-rmarkdown.yaml"
shell:
"""
cp report/RMarkdown/Hybrid_assembly_report.Rmd {config[outdir]}Hybrid_assembly_report.Rmd
Rscript -e \"tinytex::install_tinytex()\"
Rscript -e \"rmarkdown::render('{config[outdir]}Hybrid_assembly_report.Rmd')\"
rm -f {config[outdir]}Hybrid_assembly_report.Rmd {config[outdir]}Hybrid_assembly_report.tex
"""
Conda YAML:
name: r-rmarkdown
channels:
- conda-forge
- bioconda
dependencies:
- r-base=4.0.3
- r-rmarkdown=2.5
- r-tinytex=0.27
Thanks in advance.
I think I've solved the issue. Instead of calling Rscript -e, I have put the following if-statement in the setup chunk in R Markdown (Which runs before running any other code if i'm correct). I then proceeded to uninstall TinyTeX to see whether it will install for once only which it did.
knitr::opts_chunk$set(echo = TRUE)
library(knitr)
if (!tinytex:::is_tinytex()){
tinytex::install_tinytex()
}

Why am I receiving an 'sbserver not found' error when attempting to set up Google Safe Browsing Database?

I reached this GitHub repo. about google safe browsing database.
I have never used go, but I think it is required now. So I installed it using:
sudo apt install golang-go
Then, I followed the instructions in the GitHub page. I executed:
go get github.com/google/safebrowsing
But nothing installed in the path I was executing the command from. However, I proceeded to:
export PATH=$PATH:$GOPATH/bin
Then the manual says, run the following command (which is two lines, I executed the first line, then I press enter, then nothing changes. Then executed the second line separately:
go get github.com/google/safebrowsing/cmd/sbserver
sbserver -apikey $APIKEY
After executing the second line, I got this error:
Command 'sbserver' not found, did you mean:
command 'sxserver' from deb sx
command 'sb_server' from deb spambayes
command 'ssserver' from deb shadowsocks
Try: sudo apt install <deb name>
Can you please point to me what is wrong? How to install google safe browsing database?
Your PATH is wrong. You will find sbserver in $GOPATH/bin.
Try ${GOPATH}/bin/sbserver -apikey $APIKEY
If that does not work, then follow the Go installation instructions and make sure that your Go environment variables are correct.
GOPATH should look like /home/myname/go or something else that looks normal.
Your PATH should contain ${GOPATH}/bin

omz_urlencode:42: -regex-match not available for regex

Okay so i'm trying to install Homebrew, so that I can I can install nodejs and npm. However I'm using this command from brew.sh;
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Once I install Homebrew It keeps returning this error
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
The current contents of /usr/local are bin CODEOFCONDUCT.md etc lib libexec Library LICENSE.txt README.md sbin share .git .github .gitignore
omz_urlencode:42: failed to load module `zsh/regex': dlopen(/usr/local/Cellar/zsh/5.2/lib/zsh/regex.so, 9): image not found
omz_urlencode:42: -regex-match not available for regex'
I honestly have no idea what's happening here. I'm not sure If I have to symlink Homebrew up or what. But I have tried everything I know so far (which isn't much). If anyone could be kind enough to give me instructions as what too look for to solve the issue, I'm all ears.
Thank you for listening!
It seems it's a bug that have been corrected in recent version of OMZ, you should update it.
You get the output:
zsh: command not found: homebrew
Because homebrew is not a command. Try brew -v instead.
To resolve:
Warning: node-5.10.1 already installed, it's just not linked
Use brew link node
Okay so I think I have made some progress, It may have been for some weird reason I didn't have permission writes to run the 'brew link < package > ' so i ran the following command:
'sudo chown -R /usr/local/share/systemtap/tapset && brew doctor'
Once I ran 'brew link node' it successfully created 7 symlinks for the node directory on the following path;
'Linking /usr/local/Cellar/node/5.10.1... 7 symlinks created'
However, when I installed live-server via npm; I typed 'live-server -v' and it again returned 'zsh: command not found: live-server'. In addition to this it keeps telling me I have 'unbrewed dylibs':
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/libociei.dylib
So im still unsure what the exact issue is.
P.S. Apologies for not posting this correctly, as im trying to see where I can seperate it into commands like you corrected in the first post, if you could link me to a post where it tells me how to use it properly i'll be more than happy to read it.
Thanks,

apktool build apk fails

I am experiencing very annoying problems with the application apktool problem.
I do not understand what i am doing wrong, or what the problem is.
I tried this on debian , and on linux mint. I used different versions of apktool,
resulting in the same error:
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building resources...
Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, -F, /tmp/APKTOOL3630495287059303807.tmp, -I, /home/awesomename/apktool/framework/1.apk, -S, /home/awesomename/out/./res, -M, /home/awesomename/out/./AndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(Unknown Source)
at brut.androlib.Androlib.buildResourcesFull(Unknown Source)
at brut.androlib.Androlib.buildResources(Unknown Source)
at brut.androlib.Androlib.build(Unknown Source)
at brut.androlib.Androlib.build(Unknown Source)
at brut.apktool.Main.cmdBuild(Unknown Source)
at brut.apktool.Main.main(Unknown Source)
Caused by: brut.common.BrutException: could not exec command: [aapt, p, -F, /tmp/APKTOOL3630495287059303807.tmp, -I, /home/windows/apktool/framework/1.apk, -S, /home/windows/out/./res, -M, /home/windows/out/./AndroidManifest.xml]
at brut.util.OS.exec(Unknown Source)
... 7 more
Caused by: java.io.IOException: Cannot run program "aapt": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at java.lang.Runtime.exec(Runtime.java:617)
at java.lang.Runtime.exec(Runtime.java:485)
... 8 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
... 10 more
It seems it can not use aapt , but i read about apktool.
And it seems that aapt is build inside apktool , why is it not working ?
It seems there's some problem in building the resources while recompiling the apk.
what you can do is, when you decompile your apk use this command
apktool d -f -r apkfilename.apk
here -f is to replace previous decompiled apk's code and -r is to ignore the decompiling of resources.
this would prevent the resources from being decompiled and will simply copy the same resources when you recompile the apk.
In case you've been using v1 and now upgraded to v2, try manually deleting the framework file.
On windows 8 it's normally at C:\Users\YourName\apktool\framework\1.apk.
The file should be regenerated once you try to build something.
My problem was solved by deleting the \framework\1.apk, making a backup on the files I modified, ereasing the dir and decompiling the *.apk again, etc... (on linux, the path is home/[user]/apktool/...). After the update, apktool always loaded the old resource table. N
For me, I solved this problem by first clearing apktool's framework directory by typing in the terminal.
$ apktool empty-framework-dir
Afterwards I uninstalled apktool and related files by typing
$ sudo apt purge apktool
Then i went to https://bitbucket.org/iBotPeaches/apktool/downloads/ to get the latest jar file for apktool(apktool_2.5.0.jar as at the time of writing this).
On first run
$ java -jar apktool_2.5.0.jar b <MyAPP.apk> #Without ><
it works.
since I work with apktool most of the times I needed a situation where I can run apktool from anywhere so I gave the jar file execute permissions by typing
$ sudo chmod +x apktool_2.5.0.jar
Afterwards I moved it /usr/bin/ by typing
$ sudo apktool_2.5.0.jar /usr/bin/
Definitely seems like the aapt PATH problem I had awhile back. Have you added aapt to PATH? If you still have problems, I have made a good apk kit in bash to avoid all these dependency problems. It supports apktool, signapk, zipalign,adb, fastboot, and heimdall. Check it out. All you need is a current java install.
http://forum.xda-developers.com/android/development/toolkit-apk-munky-rench-t3026757/post58747626#post58747626
There isn’t really enough information to give you a definite answer.
How ever you mentioned using different versions but the aapt issue was solved in version 2.4. Dependencies have been reduced to java version 1.8 or greater and the framework.
I use Debian and have the following:
Apktool 2.4
java version 11
Android framework
That’s all it took to get rid of the aapt path error.
The last error I came across was unrelated to aapt but was on the framework so I ran this command
apktool empty-framework-dir
And it solved it.
try to put the dir which include aapt file to your PATH. for example, export PATH=$PATH:./ ./apktool b
try to install ia32-libs and update latest version of apktool. (if possible restart)
apktool requires "ia32-libs" which is not available after Ubuntu 12.04. install ia32-libs
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6
Download latest version of apktools.jar - https://bitbucket.org/iBotPeaches/apktool/downloads
apktool complete installation guide - http://ibotpeaches.github.io/Apktool/install/
I just encounter same problem when run apktool d foo.apk(decompiled success) and then apktool b foo(recompile failed with similar error).
The apktool tool above was installed via sudo apt-get install apktool on Kali Linux.
So, the solution was visits apktool's official site, e.g. https://connortumbleson.com/2017/01/23/apktool-v2-2-2-released/ (it's latest version at this time of writing), download it, md5sum it, e.g. md5sum apktool_2.2.2.jar to verify, then rename that apktool_2.2.2.jar to apktool.jar.
Then do java -jar ./apktool.jar b foo to recompile, it success without error (the generated apk located at ./foo/dist/foo.apk).
The main issue is apktool version you need 2.4.0
You must manually install it from ibotpeaches git hub
here some good info
https://www.youtube.com/watch?v=kB6s10Uwpcs
and a automated script for kali
https://github.com/catenatedgoose?tab=repositories
In my mind the problem is how you install apktool...
I had the same problem and I did this and it worked very well:
For installation you first have to remove any installed apktool by the command:
sudo apt purge apktool
Then you'll have to install apktool but in a different way.
To continue save the link bellow as apktool in a directory.
[https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool]
Then open this link below and download the latest apktool.jar file: https://bitbucket.org/iBotPeaches/apktool/downloads/
Then rename the file as apktool.jar
After that give both files the permission by the command:
Sudo chmod -x apktool.jar
And for the saved script:
Sudo chmod -x apktool
At the end copy both files in the directory:
/usr/local/bin
By the command:
Sudo cp apktool.jar /usr/local/bin
And the script file:
Sudo cp apktool /usr/local/bin
After that try running apktoolin the terminal.
The solution is to include your apktool directory into your system PATH.

PHPUnit Extension warning in Yii

I am setting up unit testing to work with the Yii framework. Apart from Yii, my PHPUnit works great. But along with Yii when I try to test it, it gives me the following warning every time.
Warning: include(PHPUnit_Extensions_Story_TestCase.php): failed to open stream:
No such file or directory in D:\xampp\htdocs\yii1112\framework\YiiBase.php on li
ne 423
Warning: include(): Failed opening 'PHPUnit_Extensions_Story_TestCase.php' for i
nclusion (include_path='.;D:\xampp\htdocs\sms_dev\protected\extensions\yii-mail;
D:\xampp\htdocs\sms_dev\protected\extensions\giix-components;D:\xampp\htdocs\sms
_dev\protected\components;D:\xampp\htdocs\sms_dev\protected\models;D:\xampp\php\
PEAR') in D:\xampp\htdocs\yii1112\framework\YiiBase.php on line 423
I have searched a lot and have also asked in the Yii forum, but nothing seems to be working out.
Does anyone have any idea what this warning means? How can I get rid of it?
The file PHPUnit_Extensions_Story_TestCase.php is part of the package PHPUnit_Story, which can be installed with:
pear install phpunit/PHPUnit_Story
See also: PHPUnit can't find PHPUnit_Extensions_Story_TestCase. What package is missing?
The protected/tests directory is not in your include path. I would suggest moving your protected directory from any public location, and just add the protected folder to the include path. so d:\xampp\htdocs\sms_dev\protected\ instead of listing each directory seperately.
Either this is the problem or the file doesn't exist and you have to check your code.
With pear install dependencies [ Now pear packages are not updated better install with composer ]
sudo pear channel-discover pear.phpunit.de
sudo pear install phpunit/PHPUnit_Story
sudo pear install phpunit/PHP_Selenium
Better if you install phpunit with composer these errors will not come
step 1:
Create a composer.json file in your project root:
{
"require-dev": {
"phpunit/phpunit": "4.6.*",
"phpunit/phpunit-selenium": ">=1.4",
"phpunit/dbunit": ">=1.3",
"phpunit/phpunit-story": "*",
"phpunit/php-invoker": "*"
},
"autoload": {
"psr-0": {"": "src"}
},
"config": {
"bin-dir": "bin/"
}
}
step 2:
Install composer into your project using:
curl -sS https://getcomposer.org/installer | php
Ensure composer is executable:
chmod +x composer.phar
Let composer install the dependencies:
./composer.phar install --dev
Check you have a project specific phpunit version installed:
bin/phpunit --version
the above specified is a softlink
ls -la bin/phpunit
bin/phpunit -> ../vendor/phpunit/phpunit/phpunit
Afterwords you can make softlink of 'phpunit' from vendor directory into directory of php in use.
This will remove all warnings related to
PHP Warning: include(classes/PHPUnit_Extensions_Story_TestCase.php)
PHP Warning: include(): Failed opening 'classes/PHPUnit_Extensions_Story_TestCase.php'
PHP Warning: include(classes/Composer\Autoload\ClassLoader.php)