Ruby FileUtils.mkpath behaves differently on different environments - ruby-on-rails

I have a rails app that contains a simple piece of code to create a directory if one does not exist.
FileUtils.mkpath(self.webapp_dir) unless File.exists?(self.webapp_dir)
This behaves as expected on my development workstation (OS X 10.9), but I'm getting errors when deployed to other environments (Red Hat 4.4.6-3).
In my rails console, I ran the following:
FileUtils.mkpath('/path/to/my/project/public/web_apps/1')
Note that on first run, 'public/web_apps/' exists, but '1' does not. This succeeds. I can run it again with the whole path already existing, and it succeeds without error every time.
Now, I try to run the same code in the rails console in the production environment. Again, 'public/web_apps/' already exists, but '1' does not. In this case I get an error.
FileUtils.mkpath('/path/to/my/project/public/web_apps/1')
--> Errno::EEXIST: File exists - /path/to/my/project/public/web_apps
Does anyone know why this behaves differently between the two machines, and what I can do about it? I suppose I could go through and check each directory in the path and create it only if it doesn't exist, but that's what I would have already expected mkpath to do.
I've found other differences between how other functions that interact with the file system behave (like how File.size does not immediately report the correct value after a file write unless you open it first). I haven't been able to find any mention of these differences in behavior in any documentation or other SO posts though, and I seem to keep stumbling upon them which is getting a little frustrating now. Is this a known thing, and how do other apps account for this?

This was actually all due to a broken sym link =(.
So web_apps was actually a sym link to a shared directory that did not exist on our servers. On my dev machine it did exist. This was not horribly obvious due to the "File exists" error.
Our deployment scripts were building the sym links without first checking if that directory actually existed. Bah.

This looks to be a permission issue, the directories are created if they DON'T exist, otherwise you don't get any errors.
Look at the owner of '/path/to/my/project/public/web_apps/'

Related

Umbraco: Restoring content. Could not get parent with Id

I'm working on an Umbraco cloud project. I pulled the website from the git repositories and built it. First thing to do there when you run the site is to restore the content that's in the development environment to the local project so we can create new features. Yet Umbraco fails to do so with the following error:
The source environment has thrown a Umbraco.Deploy.Exceptions.ProcessArtifactException
with message: Process pass #3 failed for artifact
umb://document/xxthexguidxofxsomexpagexxxxxxxxx. It might have been
caused by an inner Umbraco.Deploy.Exceptions.EnvironmentException with
message: Could not get parent with id xxthexxx-guid-xofx-xthe-xxhomepagexx.
The following artifacts might be involved:
umb://document/xxthexxxguidxofxxthexxhomepagexx
The technical details may contain more information.
I've noticed that I some strange errors occur if not everything is deployed in the development site in the cloud. So I made sure everything is published.. Still errors though... I'm kinda lost here.
Has anyone come across simular issues? And how did you fix it?
Thanks in advance?
This can happen for a number of reasons, so it's a bit hard to say what exactly the problem is in your case.
Most of the time this happens due to either a circular reference of some sort causing a state that can't really be restored. For example that could be a datatype having a dependency on a node - but the node doesn't exist in a blank new environment. The content restore then refuses to start until the structural data (datatypes, contenttypes and such) is completely in sync, but the datatypes will never be able to be in sync until the content node exists. It's a sort of catch22 situation that might need to be resolved manually.
I would suggest you contact support through the Cloud portal and they will assist you in getting your problem resolved.

.kmod and .ko - difference?

Have been using Ndisgen to try to generate a .ko kernel module for an rtl8192se driver for my Freebsd 9 netbook having followed instructions found on several different dev blogger sites.
Somehow, i've just not been able to generate a file with extension .ko. Instead, i keep getting a .kmod file.
Question is, what is the difference between these ?
I have also attempted kldload for this .kmod file. When i check it via kldstat, ok, i see it there but, when i then check with dmesg and pciconf -lv, my realtek card is still not hooked up.
So i reckon i really need to generate the .ko file in the first place, but what am i doing wrong or missing, such that only a kmod is generated?
Any pointers would be appreciated! thanks! :)
Update::
There was a message I had ignored.
My bad!
the message after conversion was :
"...Cleaning up... rm: machine: is a directory cleanup failed.Exiting"
That's all because i had pasted a copy of the "/usr/include/machine" folder with all the headers i thought was required in the path where I was converting the driver.
But i ignored it thinking, well since ndisgen had already created a .kmod file(which was what I had assumed was also a kernel module, just not in .ko form) then it was alright.
SO finally, since it's complaining that it's a directory and can't be cleaned, i then created a symbolic link to that folder instead.
Et voila! the clean was successful and now i have the .ko file! :D
The ndisgen script renames the .ko file to .kmod temporarily to do some cleanup.
If that cleanup works, it should rename it back to a .ko file. See the drvgen function /usr/src/usr.sbin/ndiscvt/ndisgen.sh.
I'm assuming that something goes wrong in between both renames. Do you get any error messages?
Keep in mind that if you load the driver, it should show up as the ndis0 device!
Looks like you are getting a NetBSD kernel module, not a FreeBSD one. See these posts:
hubertf's NetBSD Blog
Modern net bsd kernel module
Is the source code that you are using available publicly for us to try follow your steps?

Is it okay to name every project "app" in Rails 4?

I don't like the idea of hardcoding brand names in my projects. I get the feeling they might change later, and sometimes I don't even have a name yet. So, can I do rails new app for my every project and just rename the directory? What problems could arise from that?
this could result in some issues
the name of the application has some implications on the internals and using several apps named "app" might have undesired effects and bugs.
for instance, sessions and cookies are named after the app name, so they will all be the same
further more, this have effects on outside sources such as AWS buckets, github repos, and even folder names - it will be pretty hard to figure out what all those /app folders are.
so if the only app you have and are working on is called app - it shouldn't be a problem (besides the name app, which is really lame, and if you are working on it at least call it by greek letters or something..)
if you are going to work on more that one app.. do yourself, your coworkers, your file-system, github, and everything else - name your app.
Also an important side note - how can you have an app and not know what it is about?
and if the name is not suiting anymore.. change it https://github.com/morshedalam/rename
If you rename your project, you must rename it in some files too. (routes.rb, environment.rb, application.rb, ...)
Heroku, for example, let you rename your app any time with apps:rename.

DeleteAttachment failing after plugin customization

I developed a simple plugin to bar files ending in .exe from being uploaded into my jira app. I overrode the AttachFile.doValidation() method to check for .exe in the filename. If it's there I return an error.
Now when I try to delete an attachment, 9 times out of 10 it won't work. I simply get the error "Failed to delete attachment with id {id}". Nothing in the stacktrace or logs indicated that something went wrong. Then it will suddenly delete succcessfully. I've found no rhyme or reason for this.
Again, I overrode AttachFile, not DeleteAttachment, so I don't know how my fix could be related to this problem. Could it be though??
If I remove my plugin entirely, I still get an error when I delete. The error says "The action can't be completed because the file is open in Java(TM) Platform SE binary". Somehow AttachFile() is leaving a reference to the file, but I have no clue where or how to clean up.
Permissions aren't the issue, because occasionally the delete command will work. It always works when the server first starts up, and after that only periodically.
We've come to the conclusion that this is a Windows-only problem, and Linux doesn't lock files. Our production server is Linux, so I'm not going to spend anymore time on this.

Xcode won't let me create a snapshot, because I don't exist

just tried to create a snapshot of one of my projects. It didn't work, and Xcode did throw the following error at me: "Unable to create a snapshot. fatal: You don't exist. Go away!"
Source control commit doesn't work either. Ok, obviously there's something wrong with my local repository. I don't have the slightest idea, what that could possibly be, though. I have not committed in quite a while, but except some updates to Xcode itself, nothing major happened to the project folder, as far as I can remember.
So, what can I do about it? Is it possible to deactivate source control for that project and then start over again with source control with the projects current status? I don't need the previous versions anymore, so that doesn't need to be taken care of.
Thank you!
Looking into the git source code, this error message is generated only if
pw = getpwuid(getuid());
fails.
It indicates that the system wasn't able to find an entry for your user account in /etc/passwd or equivalent.
This can happen if your account is removed (via deluser, userdel, or something else) while you're logged in, or if you don't have read permissions on /etc/passwd (the latter should never happen).
Try the following commands at a terminal prompt:
whoami
id
ls -l /etc/passwd
grep "^${USER}:" /etc/passwd
According to the git documentation, this is the meaning of your particular error:
You don't exist. Go away!
The passwd(5) gecos field couldn't be read
This typically means the system doesn't know who you are (you'll see this sort of error on a Linux system if you delete someone's user account while they're still logged in). Is everything else working? That is, can you log out and log back in without a problem? Do other terminal commands operate correctly? What about the id command?
Can you interact with your repository on the command line? What happens if you cd into the directory and try something like git status?
WendiKidd's solution of just starting from scratch is probably the simplest thing to do, assuming it works, but you'll lose any change history already associated with your project.
I had this issue with git and running
dscacheutil -flushcache
in the terminal fixed it.
I would suggest creating a new project entirely, copying your code etc. files out of the old project, and simply migrating over into a new one (which you could then recommit to another source control directory). That seems like the easiest solution; this is a very odd error, and I've come across things in the past that are either unfixable or would take more effort to fix than taking 10-15 minutes to just set up a new project.
So that's what I'd recommend--hopefully that will fix your problem, and whatever xcode is mad at is in some hidden file or the .xcodeproj itself, and not in the files you'd need to migrate over.

Resources