I experience a very weird error with the GitHub API using the Octokit Ruby library. Only sometimes API requests to add new files to a repository fail with the following message:
Octokit::UnprocessableEntity: PUT https://api.github.com/repos/organization/repo/contents/config.xml: 422 - Invalid request.
"sha" wasn't supplied. // See: https://developer.github.com/v3/repos/contents/#update-a-file
from C:/Dev/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/octokit-4.8.0/lib/octokit/response/raise_error.rb:16:in `on_complete'
Here is how I am trying to upload the contents of an entire folder to GitHub:
Dir.glob(folder + '/**/*') do |path|
next if File.directory?(path)
octokit_client.create_contents 'organization/repo', path.sub("#{folder}/", ''), '🎉', File.read(path), branch: 'master'
end
If an error occurs, it does so with the first attempt to upload a file.
Edit:
I found that the error only occurs when the first file uploaded is a .xml file.
Additionally I often get ...
Octokit::RepositoryUnavailable
PUT https://api.github.com/repos/organization/repo/contents/icon/_60x60_at1x.png: 403 - Repository access blocked
... for other files but the same repository as well.
What am I doing wrong?
Make sure you don't have a file with the same name in the folder.
In this case, you are editing a file and not creating one.
Related
I wants to read a excel file existing on Live URL of another website.
When I hit that URL in browser file is downloading. While in my rails app it is giving below error
No such file or directory # rb_sysopen - http://www.carsa.jp/admin/data.xlsx (Errno::ENOENT)
My Rails app code is as below
data = Roo::Excelx.new('http://www.carsa.jp/admin/data.xlsx')
header = data.row(1)
puts header
Note: If I download file and place it within my application it is working fine but the requirement is to read it from the third-party website in a scheduled job as per the above script.
data = Roo::Excelx.new('lib/data.xlsx')
header = data.row(1)
puts header
Try using Roo::Spreadsheet.open instead of Roo::Excelx.new. According to the Roo Readme:
Roo::Spreadsheet.open can accept both paths and File instances.
This should do the trick:
Roo::Spreadsheet.open('http://www.carsa.jp/admin/data.xlsx')
I've already packaged the app correctly and am now going through the whole electron-winstaller processs, following the Christian Engvall tutorial exactly.
In createInstaller.js I have the standard
return Promise.resolve({
appDirectory: path.join(outPath, '/MyApp-win32-x64/'),
authors: 'Me',
noMsi: true,
outputDirectory: path.join(outPath, 'windows-installer'),
exe: 'MyApp.exe',
setupExe: 'Setup.exe',
setupIcon: path.join(rootPath, '/path/to/appicon.ico')
});
If I remove the setupIcon parameter, it builds the installer just fine. However if I keep it there, I get an 'Unable to load file' error from the console. I've verified that the path to the .ico file is in fact correct, and is a valid .ico file.
What could possibly be happening?
To fix the Setup Icon error when creating an installer with electron-wininstaller you can use Resource Hacker.
It is for editing the exe file and you can change the ressource file and icons.
For more information you there is a tutorial here.
I have a script that's a plugin for redmine which enhances the application to send encrypted mail using gpg. At some point this stopped working. Unfortunately the one who wrote that script is not available anymore and I am an admin with only very limited knowledge of RoR.
The problem is, that obviously the script creates a file with the mail body, saves it to temp, encrypts it to an output file, reads this output and then sends the mail.
With an empty /tmp directory (such as after rebooting the whole server), the gpg.in file gets created when I try to send a test mail. But then I get an error that the gpg.out file was not available. Creating it using touch does cause an empty email being send so obviously the script does not write anything to that file.
File.open('/tmp/gpg.in', 'w') do |f1| #<--- Works, file is created
f1.puts(body)
end
list_of_keys = [ rec ]
Gpgr::Encrypt.file('/tmp/gpg.in', :to => '/tmp/gpg.out').encrypt_using(list_of_keys) #<- gpg.out wird nicht erzeugt.
text = ""
File.open('/tmp/gpg.out', 'r') do |f2| #<- throws file not found error, if file not there. When file was created empty using touch, it sends an empty mail
With my limited RoR knowledge, I can't figure out how to debug this. Permissions on /tmp are 777 so the script should be allowed to write there and obviously has because File.open('/tmp/gpg.in', 'w') works correctly all the time without an error. Hence I expect the problem in Gpgr::Encrypt.file not working correctly, but I also don't get any error from that function it fails silently.
I am customizing the default build process template in TFS 2010.
i am using "DownloadFiles" build activity and in server path i have given "$/TFS/Libraries/Foo.DLL", when i run the execute definition its throwing error as "Access to the path '\ServerName\SharedFolder\BuildName\TempFolder' is denied.".
But when i give server path as "$/TFS/Libraries" its downloading all the files in Libraries folder into shared TempFolder.
But i need do download only one file. Please help..
Thanks in advance..
Now, DownloadFiles does work for a whole folder only:
ServerPath="$/proj/path" - works great, all is downloaded to LocalPath.
ServerPath="$/proj/path/name.ext" - borked.
I've de-compiled DownloadFiles to see why: First it gets a list of server items, in our case just $/proj/path/name.ext. Then, it calculates the local path like this:
localItemPath = Path.Combine(LocalPath,VersionControlPath.MakeRelative(ServerItem, ServerPath));
In this line, the activity assumes that ServerPath is a path. If it's not, then MakeRelative will not recognize it, and the local path will be LocalPath/$/proj/path/name.ext, as the OP has observed.
Also, if ServerPath is not canonical - for example, $/proj/path/../path2, the same will happen. Solution: use VersionControlPath.GetFullPath(myNonCanonicalPath).
You need to grant the user running the build service with write permissions on the shared folder.
http://msdn.microsoft.com/en-us/library/cc668757.aspx
There are two separate Build activities, DownloadFiles for a folder ServerItem and a DownloadFile for a single file ServerItem.I'd expect it should work with DownloadFile.
How to check that my params['Filedata'] is corrupted or not?
I have function it's reading file from params['Filedata'] and writing it to the other file.
File.open(upload_file, "wb") { |f| f.write(params['Filedata'].read) }
this line working fine for me..
But when i am calling this function with delayed job function send_later than I am getting error with params['Filedata'].read.
I'm guessing params['Filedata'] refers to a uploaded file.
Rails handles uploaded data as temporary files, which are deleted after the request is completed. If you want to access the file later, you need to copy it to a more permanent location.