Firefox SDK JPM error when trying to attach scripts on tab ready event [duplicate] - firefox-addon-sdk

This question already has an answer here:
Firefox SDK extension - JPM error [closed]
(1 answer)
Closed 6 years ago.
This started on 02-11-2016 - firefox developer edition (but apparently also the main one)
Code:
var self = require("sdk/self");
var tabs = require("sdk/tabs");
tabs.on('ready', function(tab){
tab.attach({
contentScriptFile: [self.data.url('js/my-file.js')]
})
});
console.error:
JPM [error] Message: Error: Creating URI from string failed
Stack:
sandbox#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/loader/sandbox.js:32:17
WorkerSandbox#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/content/sandbox.js:145:19
constructor#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/core/heritage.js:146:23
initialize#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/content/worker-child.js:52:20
constructor#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/core/heritage.js:146:23
#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/content/tab-events.js:51:3
emitOnObject#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:112:9
emit#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:89:38
emitOnObject#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:112:9
emit#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:89:38
emitOnObject#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:123:45
emit#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:89:38
messageReceived#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/remote/child.js:67:37
Works fine the first time it is attached, but when you navigate to another URL in the same tab, i get the above error. So probably when detaching and reattaching the script, something fails. Any help or idea is greatly appreciated and very welcomed!

Soo.. if you don't "jpm init" in the new folder, and copy-paste the contents of another, previously initialized folder, inside - you get the above error. Mistake on my part.

Related

Error in value[[3L]](cond) : there is no package called 'plotly’

I tried to deploy shiny apps to shiny.io but failed with log as below:
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne ->
Shiny application exiting ...
Attaching package: ‘shinydashboard’
Execution halted
Error in value[3L] : there is no package called ‘plotly’
===
Already tried to uninstall it in console, then re-install it, and re-deploy, but still failed.
This is my library i call in global R:
library(shiny)
library(shinydashboard)
library(glue)
library(plotly)
library(lubridate)
library(tidyverse)
library(scales)
options(scipen=123)
I am new in R, pls advise what should i do/correct
Thank you

Q# : QDK Errors

I've recently tried to install the QDK via the VSCode extension in my Windows 10 Desktop and VSCode wasn't able to find the Microsoft libraries even after I was able to execute the code by the dotnet run command on the terminal. The code was the sample project code described in the create new project part of the tutorial. I also didn't have .NET SDK so I installed it but it seems to be working fine. In computers I got problems all the code, all related to not finding the namespaces.
namespace QuantumRNG {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Measurement;
open Microsoft.Quantum.Math;
open Microsoft.Quantum.Convert;
operation GenerateRandomBit() : Result {
using (q = Qubit()) {
H(q);
return MResetZ(q);
}
}
operation SampleRandomNumberInRange(max : Int) : Int {
mutable output = 0;
repeat {
mutable bits = new Result[0];
for (idxBit in 1..BitSizeI(max)) {
set bits += [GenerateRandomBit()];
}
set output = ResultArrayAsInt(bits);
} until (output <= max);
return output;
}
#EntryPoint()
operation SampleRandomNumber() : Int {
let max = 50;
Message($"Sampling a random number between 0 and {max}: ");
return SampleRandomNumberInRange(max);
}
}
Do you see any error messages in the output console?
To see the output console select "View: Toggle Output" (Ctrl + Shift + U) and select "Q# Language Extension" from the drop down list.
If the drop down list doesn't show "Q# Language Extension" then it probably means that the language-server that gets downloaded on first run is still downloading, so give it a minute or so (depending on your internet connection).
I think I also had the same problem. The .Net SDk which you have downloaded automatically creates a path in the environment variable by the name "%USERPROFILE%.dotnet\tools" so delete this and add "C:\Program Files\dotnet\sdk" or copy the path of dotnet SDK from the drive where you have installed dotnet and create a new environment variable under user variable. This might solve your namespace problem.

Trouble reading file in xcode command line app

I am having trouble reading a file within a command line tool project in Xcode 11.6.
Steps:
Create a new command line tool project using the template in the mac os section.
In main.swift:
import Foundation
let fileURL = URL( fileURLWithPath: "/Users/ausom4/Desktop/myTest.txt" )
var rawDataString: String
var errorString: String?
do {
rawDataString = try String( contentsOf: fileURL, encoding: .utf8 )
print(rawDataString)
} catch let error as NSError {
errorString = error.description
rawDataString = ""
print(rawDataString)
}
This will build successfully in Xcode however will always print a null string in the console.
However if I go to the location of my product in terminal and run the build I get the contents of the file.
I do not have sandboxing enabled. Sandboxing is also not enabled by default in this xcode template. I have also given xcode full disk access.
I can run this code in a playground.
What could be the issue here?
It is not sandbox - it is macOS Security & Privacy system.
On first launch you had to get alert asking something like “TestFileReading” would like to access files in your Desktop folder. so you grand access for this application.
If you did not grant access then (or for some reason macOS forgot to ask that) there is possibility to grant access manually in System Preferences at any time:
With all this passed your code snippet works as expected - tested with Xcode 12 / macOS 10.15.6

sonar report with 0 bugs and vulnerabilities

I had a very strange problem when using sonar with my swift project. Although, I get usually 0 bugs and 0 vulnerabilities every statics have 0 values which really very strange. this my report:
I had installed SwiftLint, OcLint and Xcpretty recording to the documentation below:
Link sonar swift
This sonar-project.properties structure:
sonar.projectKey=testSonar
sonar.projectName=testSonar
sonar.project=TestSonar.xcodeproj
sonar.projectVersion=1.0
sonar.host.url=http://localhost:9000
sonar.login=admin
sonar.password=admin
sonar.language=swift
sonar.exclusions=**/*.xml,Pods/**/*,Reports/**/*
sonar.swift.simulator=platform=iOS Simulator,name=iPhone X,OS=latest
sonar.sourceEncoding=UTF-8
sonar.junit.reportsPath=sonar-reports/
sonar.swift.lizard.report=sonar-reports/lizard-report.xml
sonar.swift.coverage.reportPattern=sonar-reports/coverage-swift*.xml
sonar.swift.swiftlint.report=sonar-reports/*swiftlint.txt
I also added the plugin for the swift version like so :
To scan I installed using brew the sonarScanner. Finally, I run this command sonar-scanner so It launch the scan and It work fine but no errors despite I made error like this:
class ViewController: UIViewController {
let var x = 3
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
Any help please ??
I fixed the problem by using run-sonar-swift.sh and updating my properties file like this:
sonar.host.url=http://localhost:9000
sonar.login=admin
sonar.password=admin
sonar.projectKey=testSonar
sonar.projectName=testSonar
sonar.language=swift
sonar.sources=.
sonar.test.inclusions=*.swift
sonar.exclusions=**/*.xml,Pods/**/*,Reports/**/*
# Scheme to build your application
sonar.swift.appScheme=TestSonar
sonar.swift.appConfiguration=Debug
you need also to download this run-sonar-swift sh file
run-sonar-swift

Using CleanroomLogger in a Swift script fails to resolve DefaultLogConfiguration

I'm just starting to play with Swift 2.0 for scripting and running into an issue with symbols being resolved.
Using Carthage I bootstrap from a Cartfile containing
github "emaloney/CleanroomLogger"
I am able to get CleanroomLogger working inside of Playground by:
Create a Workspace inside of XCode 7.1.1
Add the CleanroomLogger.xcodeproj file from ./Carthage/Checkouts/CleanroomLogger
Create a new Playground in the project
Inside of the playground I enter the code
import CleanroomLogger
var logConfig = DefaultLogConfiguration.init(minimumSeverity: LogSeverity.Debug, synchronousMode: true)
Log.enable(logConfig)
Log.debug?.message("Sample message sent to debug")
Log.debug?.value("Sample value sent to debug")
This plays without error. I only see () as the output in the playground next to each Log.debug? call which is expected. If I open up the Console app I see two entries:
11/20/15 10:33:51.455 PM Cleanroom Logger[70056]: DEBUG | <EXPR>:5 — Sample message sent to debug
11/20/15 10:33:51.455 PM Cleanroom Logger[70056]: DEBUG | <EXPR>:6 — <String: "Sample value sent to debug">
So clearly I have CleanroomLogger checked out and properly built at this point.
I proceed to try and use Cleanroom Logger from a script logger-demo.swift located in the same directory as my Cartfile. This script is identical to the playground code with the addition of the shebang at the start
#!/usr/bin/env swift -F Carthage/Build/Mac
import CleanroomLogger
var logConfig = DefaultLogConfiguration.init(minimumSeverity: LogSeverity.Debug, synchronousMode: true)
Log.enable(logConfig)
Log.debug?.message("Hello from inside my Mac")
Log.debug?.value("This is a test of value")
Running the script results in the following output:
$ ./logger-demo.swift
LLVM ERROR: Program used external function '__TMdV15CleanroomLogger23DefaultLogConfiguration' which could not be resolved!
Why would this resolve in a playground but not from a swift script?
Wow, that sounds complicated ...
Maybe try SwiftyBeaver logger for Swift 2 instead. It is simple(!), supports colors, is fast & is much more feature-complete.
P.S.: I am the creator :)